ActivityPub-federated video streaming platform using P2P directly in your web browser
Enable video upload and edit
clementbrizard1e74f19a2179
diff --git a/client/src/app/shared/forms/form-validators/video-validators.service.ts b/client/src/app/shared/forms/form-validators/video-validators.service.tsindex 81ed0666f1..e3f7a0969d 100644--- a/client/src/app/shared/forms/form-validators/video-validators.service.ts+++ b/client/src/app/shared/forms/form-validators/video-validators.service.ts@@ -16,6 +16,7 @@ export class VideoValidatorsService {readonly VIDEO_TAGS: BuildFormValidatorreadonly VIDEO_SUPPORT: BuildFormValidatorreadonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator+ readonly VIDEO_ORIGINALLY_PUBLISHED_AT: BuildFormValidatorconstructor (private i18n: I18n) {@@ -92,5 +93,10 @@ export class VideoValidatorsService {'required': this.i18n('A date is required to schedule video update.')}}++ this.VIDEO_ORIGINALLY_PUBLISHED_AT = {+ VALIDATORS: [ ],+ MESSAGES: {}+ }}}diff --git a/client/src/app/shared/video-import/video-import.service.ts b/client/src/app/shared/video-import/video-import.service.tsindex 7ae66ddfcd..11a7694c89 100644--- a/client/src/app/shared/video-import/video-import.service.ts+++ b/client/src/app/shared/video-import/video-import.service.ts@@ -67,6 +67,7 @@ export class VideoImportService {const description = video.description || nullconst support = video.support || nullconst scheduleUpdate = video.scheduleUpdate || null+ const originallyPublishedAt = video.originallyPublishedAt || nullreturn {name: video.name,@@ -83,7 +84,8 @@ export class VideoImportService {commentsEnabled: video.commentsEnabled,thumbnailfile: video.thumbnailfile,previewfile: video.previewfile,- scheduleUpdate+ scheduleUpdate,+ originallyPublishedAt}}diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.tsindex 55844f9881..5d258891f8 100644--- a/client/src/app/shared/video/video.service.ts+++ b/client/src/app/shared/video/video.service.ts@@ -81,6 +81,7 @@ export class VideoService implements VideosProvider {const description = video.description || nullconst support = video.support || nullconst scheduleUpdate = video.scheduleUpdate || null+ const originallyPublishedAt = video.originallyPublishedAt || nullconst body: VideoUpdate = {name: video.name,@@ -97,7 +98,8 @@ export class VideoService implements VideosProvider {commentsEnabled: video.commentsEnabled,thumbnailfile: video.thumbnailfile,previewfile: video.previewfile,- scheduleUpdate+ scheduleUpdate,+ originallyPublishedAt}const data = objectToFormData(body)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.htmlindex bd52d686a7..23a71a0685 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@@ -114,6 +114,20 @@</div></div>+ <div class="form-group">+ <label i18n for="originallyPublishedAt">Original publication date</label>+ <my-help i18n-preHtml preHtml="This is the date when the content was originally published (e.g. the release date for a film)"></my-help>+ <p-calendar+ id="originallyPublishedAt" formControlName="originallyPublishedAt" [dateFormat]="calendarDateFormat"+ [locale]="calendarLocale" [showTime]="true" [hideOnDateTimeSelect]="true" [monthNavigator]="true" [yearNavigator]="true" [yearRange]="myYearRange"+ >+ </p-calendar>++ <div *ngIf="formErrors.originallyPublishedAt" class="form-error">+ {{ formErrors.originallyPublishedAt }}+ </div>+ </div>+<my-peertube-checkboxinputName="nsfw" formControlName="nsfw"i18n-labelText labelText="This video contains mature or explicit content"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.tsindex 85e0159010..d02f18ee94 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@@ -45,6 +45,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {calendarLocale: any = {}minScheduledDate = new Date()+ myYearRange = '1880:' + (new Date()).getFullYear()calendarTimezone: stringcalendarDateFormat: string@@ -99,7 +100,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {thumbnailfile: null,previewfile: null,support: this.videoValidatorsService.VIDEO_SUPPORT,- schedulePublicationAt: this.videoValidatorsService.VIDEO_SCHEDULE_PUBLICATION_AT+ schedulePublicationAt: this.videoValidatorsService.VIDEO_SCHEDULE_PUBLICATION_AT,+ originallyPublishedAt: this.videoValidatorsService.VIDEO_ORIGINALLY_PUBLISHED_AT}this.formValidatorService.updateForm(diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.tsindex 33521a8c13..b26dcabe17 100644--- a/server/controllers/api/videos/index.ts+++ b/server/controllers/api/videos/index.ts@@ -188,7 +188,8 @@ async function addVideo (req: express.Request, res: express.Response) {support: videoInfo.support,privacy: videoInfo.privacy,duration: videoPhysicalFile['duration'], // duration was added by a previous middleware- channelId: res.locals.videoChannel.id+ channelId: res.locals.videoChannel.id,+ originallyPublishedAt: videoInfo.originallyPublishedAt}const video = new VideoModel(videoData)video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object@@ -325,6 +326,11 @@ async function updateVideo (req: express.Request, res: express.Response) {if (videoInfoToUpdate.support !== undefined) videoInstance.set('support', videoInfoToUpdate.support)if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description)if (videoInfoToUpdate.commentsEnabled !== undefined) videoInstance.set('commentsEnabled', videoInfoToUpdate.commentsEnabled)+ if (videoInfoToUpdate.originallyPublishedAt !== undefined &&+ videoInfoToUpdate.originallyPublishedAt !== null) {+ videoInstance.set('originallyPublishedAt', videoInfoToUpdate.originallyPublishedAt)+ }+if (videoInfoToUpdate.privacy !== undefined) {const newPrivacy = parseInt(videoInfoToUpdate.privacy.toString(), 10)videoInstance.set('privacy', newPrivacy)diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.tsindex e6f22e6c52..ce4492a306 100644--- a/server/helpers/custom-validators/videos.ts+++ b/server/helpers/custom-validators/videos.ts@@ -13,7 +13,7 @@ import {VIDEO_STATES} from '../../initializers'import { VideoModel } from '../../models/video/video'-import { exists, isArray, isFileValid } from './misc'+import { exists, isArray, isDateValid, isFileValid } from './misc'import { VideoChannelModel } from '../../models/video/video-channel'import { UserModel } from '../../models/account/user'import * as magnetUtil from 'magnet-uri'@@ -115,6 +115,10 @@ function isScheduleVideoUpdatePrivacyValid (value: number) {)}+function isVideoOriginallyPublishedAtValid (value: string | null) {+ return value === null || isDateValid(value)+}+function isVideoFileInfoHashValid (value: string | null | undefined) {return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH)}@@ -220,6 +224,7 @@ export {isVideoTagsValid,isVideoFPSResolutionValid,isScheduleVideoUpdatePrivacyValid,+ isVideoOriginallyPublishedAtValid,isVideoFile,isVideoMagnetUriValid,isVideoStateValid,diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.tsindex 051a19e16f..194d12c6e5 100644--- a/server/middlewares/validators/videos/videos.ts+++ b/server/middlewares/validators/videos/videos.ts@@ -14,6 +14,7 @@ import {} from '../../../helpers/custom-validators/misc'import {checkUserCanManageVideo,+ isVideoOriginallyPublishedAtValid,isScheduleVideoUpdatePrivacyValid,isVideoCategoryValid,isVideoChannelOfAccountExist,@@ -340,6 +341,10 @@ function getCommonVideoAttributes () {.optional().toBoolean().custom(isBooleanValid).withMessage('Should have comments enabled boolean'),+ body('originallyPublishedAt')+ .optional()+ .customSanitizer(toValueOrNull)+ .custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'),body('scheduleUpdate').optional()