readonly VIDEO_TAGS: BuildFormValidator
readonly VIDEO_SUPPORT: BuildFormValidator
readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator
+ readonly VIDEO_ORIGINALLY_PUBLISHED_AT: BuildFormValidator
constructor (private i18n: I18n) {
'required': this.i18n('A date is required to schedule video update.')
}
}
+
+ this.VIDEO_ORIGINALLY_PUBLISHED_AT = {
+ VALIDATORS: [ ],
+ MESSAGES: {}
+ }
}
}
const description = video.description || null
const support = video.support || null
const scheduleUpdate = video.scheduleUpdate || null
+ const originallyPublishedAt = video.originallyPublishedAt || null
return {
name: video.name,
commentsEnabled: video.commentsEnabled,
thumbnailfile: video.thumbnailfile,
previewfile: video.previewfile,
- scheduleUpdate
+ scheduleUpdate,
+ originallyPublishedAt
}
}
const description = video.description || null
const support = video.support || null
const scheduleUpdate = video.scheduleUpdate || null
+ const originallyPublishedAt = video.originallyPublishedAt || null
const body: VideoUpdate = {
name: video.name,
commentsEnabled: video.commentsEnabled,
thumbnailfile: video.thumbnailfile,
previewfile: video.previewfile,
- scheduleUpdate
+ scheduleUpdate,
+ originallyPublishedAt
}
const data = objectToFormData(body)
</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-checkbox
inputName="nsfw" formControlName="nsfw"
i18n-labelText labelText="This video contains mature or explicit content"
calendarLocale: any = {}
minScheduledDate = new Date()
+ myYearRange = '1880:' + (new Date()).getFullYear()
calendarTimezone: string
calendarDateFormat: string
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(
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
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)
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'
)
}
+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)
}
isVideoTagsValid,
isVideoFPSResolutionValid,
isScheduleVideoUpdatePrivacyValid,
+ isVideoOriginallyPublishedAtValid,
isVideoFile,
isVideoMagnetUriValid,
isVideoStateValid,
} from '../../../helpers/custom-validators/misc'
import {
checkUserCanManageVideo,
+ isVideoOriginallyPublishedAtValid,
isScheduleVideoUpdatePrivacyValid,
isVideoCategoryValid,
isVideoChannelOfAccountExist,
.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()