ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix comments/download attributes on import
Chocobozzz0146f3516ec4
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.tsindex c369ba2b7a..da49969025 100644--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts+++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts@@ -1,3 +1,4 @@+import { switchMap } from 'rxjs'import { AfterViewInit, Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'import { Router } from '@angular/router'import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'@@ -87,21 +88,16 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Afthis.loadingBar.useRef().start()this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate)+ .pipe(switchMap(({ video }) => this.videoService.getVideo({ videoId: video.uuid }))).subscribe({- next: res => {+ next: video => {this.loadingBar.useRef().complete()- this.firstStepDone.emit(res.video.name)+ this.firstStepDone.emit(video.name)this.isImportingVideo = falsethis.hasImportedVideo = true- this.video = new VideoEdit(Object.assign(res.video, {- commentsEnabled: videoUpdate.commentsEnabled,- downloadEnabled: videoUpdate.downloadEnabled,- privacy: { id: this.firstStepPrivacyId },- support: null,- thumbnailUrl: null,- previewUrl: null- }))+ this.video = new VideoEdit(video)+ this.video.patch({ privacy: this.firstStepPrivacyId })hydrateFormFromVideo(this.form, this.video, false)},diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.tsindex 4c74eda845..971a2a070e 100644--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts+++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts@@ -1,8 +1,9 @@+import { forkJoin } from 'rxjs'import { map, switchMap } from 'rxjs/operators'import { AfterViewInit, Component, EventEmitter, OnInit, Output } from '@angular/core'import { Router } from '@angular/router'import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'-import { getAbsoluteAPIUrl, scrollToTop } from '@app/helpers'+import { scrollToTop } from '@app/helpers'import { FormValidatorService } from '@app/shared/shared-forms'import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main'import { LoadingBarService } from '@ngx-loading-bar/core'@@ -76,12 +77,11 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterVthis.videoImportService.importVideoUrl(this.targetUrl, videoUpdate).pipe(- switchMap(res => {- return this.videoCaptionService- .listCaptions(res.video.uuid)- .pipe(- map(result => ({ video: res.video, videoCaptions: result.data }))- )+ switchMap(previous => {+ return forkJoin([+ this.videoCaptionService.listCaptions(previous.video.uuid),+ this.videoService.getVideo({ videoId: previous.video.uuid })+ ]).pipe(map(([ videoCaptionsResult, video ]) => ({ videoCaptions: videoCaptionsResult.data, video })))})).subscribe({@@ -91,24 +91,8 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterVthis.isImportingVideo = falsethis.hasImportedVideo = true- const absoluteAPIUrl = getAbsoluteAPIUrl()-- const thumbnailUrl = video.thumbnailPath- ? absoluteAPIUrl + video.thumbnailPath- : null-- const previewUrl = video.previewPath- ? absoluteAPIUrl + video.previewPath- : null-- this.video = new VideoEdit(Object.assign(video, {- commentsEnabled: videoUpdate.commentsEnabled,- downloadEnabled: videoUpdate.downloadEnabled,- privacy: { id: this.firstStepPrivacyId },- support: null,- thumbnailUrl,- previewUrl- }))+ this.video = new VideoEdit(video)+ this.video.patch({ privacy: this.firstStepPrivacyId })this.videoCaptions = videoCaptionsdiff --git a/client/src/app/+videos/+video-edit/video-update.component.html b/client/src/app/+videos/+video-edit/video-update.component.htmlindex ffd125695b..a33ac3db4c 100644--- a/client/src/app/+videos/+video-edit/video-update.component.html+++ b/client/src/app/+videos/+video-edit/video-update.component.html@@ -1,7 +1,7 @@<div class="margin-content"><div class="title-page"><span class="me-1" i18n>Update</span>- <a [routerLink]="getVideoUrl()">{{ video?.name }}</a>+ <a [routerLink]="getVideoUrl()">{{ videoDetails?.name }}</a></div><form novalidate [formGroup]="form">diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.tsindex 43e8ba3e56..13e786a8ee 100644--- a/client/src/app/+videos/+video-edit/video-update.component.ts+++ b/client/src/app/+videos/+video-edit/video-update.component.ts@@ -18,7 +18,7 @@ import { VideoSource } from '@shared/models/videos/video-source'templateUrl: './video-update.component.html'})export class VideoUpdateComponent extends FormReactive implements OnInit {- video: VideoEdit+ videoEdit: VideoEditvideoDetails: VideoDetailsvideoSource: VideoSourceuserVideoChannels: SelectChannelItem[] = []@@ -50,19 +50,19 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {const { videoData } = this.route.snapshot.dataconst { video, videoChannels, videoCaptions, videoSource, liveVideo } = videoData- this.video = new VideoEdit(video)this.videoDetails = video+ this.videoEdit = new VideoEdit(this.videoDetails)this.userVideoChannels = videoChannelsthis.videoCaptions = videoCaptionsthis.videoSource = videoSourcethis.liveVideo = liveVideo- this.forbidScheduledPublication = this.video.privacy !== VideoPrivacy.PRIVATE+ this.forbidScheduledPublication = this.videoEdit.privacy !== VideoPrivacy.PRIVATE}onFormBuilt () {- hydrateFormFromVideo(this.form, this.video, true)+ hydrateFormFromVideo(this.form, this.videoEdit, true)if (this.liveVideo) {this.form.patchValue({@@ -115,16 +115,16 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {return}- this.video.patch(this.form.value)+ this.videoEdit.patch(this.form.value)this.loadingBar.useRef().start()this.isUpdatingVideo = true// Update the video- this.videoService.updateVideo(this.video)+ this.videoService.updateVideo(this.videoEdit).pipe(// Then update captions- switchMap(() => this.videoCaptionService.updateCaptions(this.video.id, this.videoCaptions)),+ switchMap(() => this.videoCaptionService.updateCaptions(this.videoEdit.id, this.videoCaptions)),switchMap(() => {if (!this.liveVideo) return of(undefined)@@ -140,7 +140,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {.some(key => this.liveVideo[key] !== liveVideoUpdate[key])if (!liveChanged) return of(undefined)- return this.liveVideoService.updateLive(this.video.id, liveVideoUpdate)+ return this.liveVideoService.updateLive(this.videoEdit.id, liveVideoUpdate)})).subscribe({@@ -149,7 +149,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {this.isUpdatingVideo = falsethis.loadingBar.useRef().complete()this.notifier.success($localize`Video updated.`)- this.router.navigateByUrl(Video.buildWatchUrl(this.video))+ this.router.navigateByUrl(Video.buildWatchUrl(this.videoEdit))},error: err => {@@ -162,10 +162,10 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {}hydratePluginFieldsFromVideo () {- if (!this.video.pluginData) return+ if (!this.videoEdit.pluginData) returnthis.form.patchValue({- pluginData: this.video.pluginData+ pluginData: this.videoEdit.pluginData})}diff --git a/client/src/app/shared/shared-main/video/video-edit.model.ts b/client/src/app/shared/shared-main/video/video-edit.model.tsindex 3922ee42a9..4cff01653f 100644--- a/client/src/app/shared/shared-main/video/video-edit.model.ts+++ b/client/src/app/shared/shared-main/video/video-edit.model.ts@@ -1,4 +1,6 @@-import { Video, VideoPrivacy, VideoScheduleUpdate, VideoUpdate } from '@shared/models'+import { getAbsoluteAPIUrl } from '@app/helpers'+import { VideoPrivacy, VideoScheduleUpdate, VideoUpdate } from '@shared/models'+import { VideoDetails } from './video-details.model'export class VideoEdit implements VideoUpdate {static readonly SPECIAL_SCHEDULED_PRIVACY = -1@@ -29,40 +31,34 @@ export class VideoEdit implements VideoUpdate {pluginData?: any- constructor (- video?: Video & {- tags: string[]- commentsEnabled: boolean- downloadEnabled: boolean- support: string- thumbnailUrl: string- previewUrl: string- }) {- if (video) {- this.id = video.id- this.uuid = video.uuid- this.shortUUID = video.shortUUID- this.category = video.category.id- this.licence = video.licence.id- this.language = video.language.id- this.description = video.description- this.name = video.name- this.tags = video.tags- this.nsfw = video.nsfw- this.commentsEnabled = video.commentsEnabled- this.downloadEnabled = video.downloadEnabled- this.waitTranscoding = video.waitTranscoding- this.channelId = video.channel.id- this.privacy = video.privacy.id- this.support = video.support- this.thumbnailUrl = video.thumbnailUrl- this.previewUrl = video.previewUrl-- this.scheduleUpdate = video.scheduledUpdate- this.originallyPublishedAt = video.originallyPublishedAt ? new Date(video.originallyPublishedAt) : null-- this.pluginData = video.pluginData- }+ constructor (video?: VideoDetails) {+ if (!video) return++ this.id = video.id+ this.uuid = video.uuid+ this.shortUUID = video.shortUUID+ this.category = video.category.id+ this.licence = video.licence.id+ this.language = video.language.id+ this.description = video.description+ this.name = video.name+ this.tags = video.tags+ this.nsfw = video.nsfw+ this.waitTranscoding = video.waitTranscoding+ this.channelId = video.channel.id+ this.privacy = video.privacy.id+ this.commentsEnabled = video.commentsEnabled+ this.downloadEnabled = video.downloadEnabled++ if (video.thumbnailPath) this.thumbnailUrl = getAbsoluteAPIUrl() + video.thumbnailPath+ if (video.previewPath) this.previewUrl = getAbsoluteAPIUrl() + video.previewPath++ this.scheduleUpdate = video.scheduledUpdate+ this.originallyPublishedAt = video.originallyPublishedAt+ ? new Date(video.originallyPublishedAt)+ : null++ this.pluginData = video.pluginData}patch (values: { [ id: string ]: any }) {@@ -86,7 +82,7 @@ export class VideoEdit implements VideoUpdate {// Convert originallyPublishedAt to string so that function objectToFormData() works correctlyif (this.originallyPublishedAt) {- const originallyPublishedAt = new Date(values['originallyPublishedAt'])+ const originallyPublishedAt = new Date(this.originallyPublishedAt)this.originallyPublishedAt = originallyPublishedAt.toISOString()}