From a5cf76afa378aae81af2a9b0ce548e5d2582f832 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 25 Sep 2020 10:04:21 +0200 Subject: [PATCH] Add watch messages if live has not started --- .../app/+admin/system/jobs/jobs.component.ts | 1 + ...ount-notification-preferences.component.ts | 2 +- .../shared/video-edit.component.html | 10 +- .../shared/video-edit.component.ts | 4 +- .../video-go-live.component.html | 2 +- .../video-go-live.component.ts | 16 +-- .../+video-edit/video-update.component.html | 2 +- .../+video-edit/video-update.component.ts | 8 +- .../+video-edit/video-update.resolver.ts | 6 +- .../+video-watch/video-watch.component.html | 10 +- .../+video-watch/video-watch.component.scss | 5 +- .../+video-watch/video-watch.component.ts | 59 +++++++- client/src/app/core/core.module.ts | 4 +- client/src/app/core/notification/index.ts | 2 +- .../notification/peertube-socket.service.ts | 86 ++++++++++++ .../user-notification-socket.service.ts | 44 ------ .../app/menu/avatar-notification.component.ts | 6 +- .../shared/shared-main/shared-main.module.ts | 4 +- .../users/user-notification.service.ts | 10 +- .../src/app/shared/shared-main/video/index.ts | 2 +- ...-live.service.ts => live-video.service.ts} | 8 +- .../video-share.component.html | 6 +- .../video-actions-dropdown.component.ts | 5 +- config/default.yaml | 11 ++ config/test.yaml | 2 +- server/initializers/constants.ts | 10 +- server/lib/activitypub/videos.ts | 3 + .../job-queue/handlers/video-live-ending.ts | 47 +++++++ server/lib/job-queue/job-queue.ts | 20 ++- server/lib/live-manager.ts | 129 ++++++++++++------ server/lib/peertube-socket.ts | 30 +++- server/lib/video-blacklist.ts | 5 + server/models/video/video-live.ts | 30 +++- .../models/video/video-streaming-playlist.ts | 11 ++ server/models/video/video.ts | 8 ++ shared/models/server/job.model.ts | 5 + shared/models/videos/index.ts | 3 +- shared/models/videos/live/index.ts | 3 + .../live/live-video-event-payload.model.ts | 5 + .../videos/live/live-video-event.type.ts | 1 + .../live-video.model.ts} | 2 +- 41 files changed, 468 insertions(+), 159 deletions(-) create mode 100644 client/src/app/core/notification/peertube-socket.service.ts delete mode 100644 client/src/app/core/notification/user-notification-socket.service.ts rename client/src/app/shared/shared-main/video/{video-live.service.ts => live-video.service.ts} (74%) create mode 100644 server/lib/job-queue/handlers/video-live-ending.ts create mode 100644 shared/models/videos/live/index.ts create mode 100644 shared/models/videos/live/live-video-event-payload.model.ts create mode 100644 shared/models/videos/live/live-video-event.type.ts rename shared/models/videos/{video-live.model.ts => live/live-video.model.ts} (57%) diff --git a/client/src/app/+admin/system/jobs/jobs.component.ts b/client/src/app/+admin/system/jobs/jobs.component.ts index 25d75aed2..602362fe9 100644 --- a/client/src/app/+admin/system/jobs/jobs.component.ts +++ b/client/src/app/+admin/system/jobs/jobs.component.ts @@ -32,6 +32,7 @@ export class JobsComponent extends RestTable implements OnInit { 'video-import', 'videos-views', 'activitypub-refresher', + 'video-live-ending', 'video-redundancy' ] diff --git a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts index bcbea7fad..ad7497f45 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts @@ -86,7 +86,7 @@ export class MyAccountNotificationPreferencesComponent implements OnInit { } private savePreferencesImpl () { - this.userNotificationService.updateNotificationSettings(this.user, this.user.notificationSettings) + this.userNotificationService.updateNotificationSettings(this.user.notificationSettings) .subscribe( () => { this.notifier.success($localize`Preferences saved`, undefined, 2000) diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.html b/client/src/app/+videos/+video-edit/shared/video-edit.component.html index c444dd8d3..0802e906d 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.html +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.html @@ -195,7 +195,7 @@ - + Live settings @@ -203,13 +203,13 @@
- - + +
- - + +
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts index bee65184b..304bf7ed0 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts @@ -20,7 +20,7 @@ import { import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms' import { InstanceService } from '@app/shared/shared-instance' import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' -import { ServerConfig, VideoConstant, VideoLive, VideoPrivacy } from '@shared/models' +import { ServerConfig, VideoConstant, LiveVideo, VideoPrivacy } from '@shared/models' import { RegisterClientFormFieldOptions, RegisterClientVideoFieldOptions } from '@shared/models/plugins/register-client-form-field.model' import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' @@ -42,7 +42,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { @Input() videoCaptions: (VideoCaptionEdit & { captionPath?: string })[] = [] @Input() waitTranscodingEnabled = true @Input() type: VideoEditType - @Input() videoLive: VideoLive + @Input() liveVideo: LiveVideo @ViewChild('videoCaptionAddModal', { static: true }) videoCaptionAddModal: VideoCaptionAddModalComponent diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.html b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.html index 6997f5388..8fae4044a 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.html +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.html @@ -31,7 +31,7 @@
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts index 64fd4c4d4..0a9efc693 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts @@ -4,9 +4,9 @@ import { Router } from '@angular/router' import { AuthService, CanComponentDeactivate, Notifier, ServerService } from '@app/core' import { scrollToTop } from '@app/helpers' import { FormValidatorService } from '@app/shared/shared-forms' -import { VideoCaptionService, VideoEdit, VideoService, VideoLiveService } from '@app/shared/shared-main' +import { LiveVideoService, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' import { LoadingBarService } from '@ngx-loading-bar/core' -import { VideoCreate, VideoLive, VideoPrivacy } from '@shared/models' +import { LiveVideo, VideoCreate, VideoPrivacy } from '@shared/models' import { VideoSend } from './video-send' @Component({ @@ -23,7 +23,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, CanCompon isInUpdateForm = false - videoLive: VideoLive + liveVideo: LiveVideo videoId: number videoUUID: string error: string @@ -38,7 +38,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, CanCompon protected serverService: ServerService, protected videoService: VideoService, protected videoCaptionService: VideoCaptionService, - private videoLiveService: VideoLiveService, + private liveVideoService: LiveVideoService, private router: Router ) { super() @@ -69,7 +69,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, CanCompon const toPatch = Object.assign({}, video, { privacy: this.firstStepPrivacyId }) this.form.patchValue(toPatch) - this.videoLiveService.goLive(video).subscribe( + this.liveVideoService.goLive(video).subscribe( res => { this.videoId = res.video.id this.videoUUID = res.video.uuid @@ -114,10 +114,10 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, CanCompon } private fetchVideoLive () { - this.videoLiveService.getVideoLive(this.videoId) + this.liveVideoService.getVideoLive(this.videoId) .subscribe( - videoLive => { - this.videoLive = videoLive + liveVideo => { + this.liveVideo = liveVideo }, err => { diff --git a/client/src/app/+videos/+video-edit/video-update.component.html b/client/src/app/+videos/+video-edit/video-update.component.html index 5f50ddc74..f290fd136 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.html +++ b/client/src/app/+videos/+video-edit/video-update.component.html @@ -11,7 +11,7 @@ [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels" [videoCaptions]="videoCaptions" [waitTranscodingEnabled]="waitTranscodingEnabled" type="update" (pluginFieldsAdded)="hydratePluginFieldsFromVideo()" - [videoLive]="videoLive" + [liveVideo]="liveVideo" >
diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts index c0f46acd2..ec1305a33 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.ts +++ b/client/src/app/+videos/+video-edit/video-update.component.ts @@ -5,7 +5,7 @@ import { Notifier } from '@app/core' import { FormReactive, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms' import { VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main' import { LoadingBarService } from '@ngx-loading-bar/core' -import { VideoPrivacy, VideoLive } from '@shared/models' +import { LiveVideo, VideoPrivacy } from '@shared/models' import { hydrateFormFromVideo } from './shared/video-edit-utils' @Component({ @@ -17,7 +17,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { video: VideoEdit userVideoChannels: SelectChannelItem[] = [] videoCaptions: VideoCaptionEdit[] = [] - videoLive: VideoLive + liveVideo: LiveVideo isUpdatingVideo = false schedulePublicationPossible = false @@ -42,11 +42,11 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { this.route.data .pipe(map(data => data.videoData)) - .subscribe(({ video, videoChannels, videoCaptions, videoLive }) => { + .subscribe(({ video, videoChannels, videoCaptions, liveVideo }) => { this.video = new VideoEdit(video) this.userVideoChannels = videoChannels this.videoCaptions = videoCaptions - this.videoLive = videoLive + this.liveVideo = liveVideo this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE diff --git a/client/src/app/+videos/+video-edit/video-update.resolver.ts b/client/src/app/+videos/+video-edit/video-update.resolver.ts index 3a82324c3..b7ec22dd5 100644 --- a/client/src/app/+videos/+video-edit/video-update.resolver.ts +++ b/client/src/app/+videos/+video-edit/video-update.resolver.ts @@ -2,13 +2,13 @@ import { forkJoin, of } from 'rxjs' import { map, switchMap } from 'rxjs/operators' import { Injectable } from '@angular/core' import { ActivatedRouteSnapshot, Resolve } from '@angular/router' -import { VideoCaptionService, VideoChannelService, VideoDetails, VideoLiveService, VideoService } from '@app/shared/shared-main' +import { VideoCaptionService, VideoChannelService, VideoDetails, LiveVideoService, VideoService } from '@app/shared/shared-main' @Injectable() export class VideoUpdateResolver implements Resolve { constructor ( private videoService: VideoService, - private videoLiveService: VideoLiveService, + private liveVideoService: LiveVideoService, private videoChannelService: VideoChannelService, private videoCaptionService: VideoCaptionService ) { @@ -49,7 +49,7 @@ export class VideoUpdateResolver implements Resolve { ), video.isLive - ? this.videoLiveService.getVideoLive(video.id) + ? this.liveVideoService.getVideoLive(video.id) : of(undefined) ] } diff --git a/client/src/app/+videos/+video-watch/video-watch.component.html b/client/src/app/+videos/+video-watch/video-watch.component.html index 0d1768aa9..13242a2bc 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.html +++ b/client/src/app/+videos/+video-watch/video-watch.component.html @@ -29,6 +29,14 @@ This video will be published on {{ video.scheduledUpdate.updateAt | date: 'full' }}.
+
+ This live has not started yet. +
+ +
+ This live is finished. +
+
This video is blocked.
{{ video.blockedReason }} @@ -113,7 +121,7 @@
- +