Enable video upload and edit
This commit is contained in:
parent
c80341655f
commit
1e74f19a21
|
@ -16,6 +16,7 @@ export class VideoValidatorsService {
|
||||||
readonly VIDEO_TAGS: BuildFormValidator
|
readonly VIDEO_TAGS: BuildFormValidator
|
||||||
readonly VIDEO_SUPPORT: BuildFormValidator
|
readonly VIDEO_SUPPORT: BuildFormValidator
|
||||||
readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator
|
readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator
|
||||||
|
readonly VIDEO_ORIGINALLY_PUBLISHED_AT: BuildFormValidator
|
||||||
|
|
||||||
constructor (private i18n: I18n) {
|
constructor (private i18n: I18n) {
|
||||||
|
|
||||||
|
@ -92,5 +93,10 @@ export class VideoValidatorsService {
|
||||||
'required': this.i18n('A date is required to schedule video update.')
|
'required': this.i18n('A date is required to schedule video update.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.VIDEO_ORIGINALLY_PUBLISHED_AT = {
|
||||||
|
VALIDATORS: [ ],
|
||||||
|
MESSAGES: {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ export class VideoImportService {
|
||||||
const description = video.description || null
|
const description = video.description || null
|
||||||
const support = video.support || null
|
const support = video.support || null
|
||||||
const scheduleUpdate = video.scheduleUpdate || null
|
const scheduleUpdate = video.scheduleUpdate || null
|
||||||
|
const originallyPublishedAt = video.originallyPublishedAt || null
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: video.name,
|
name: video.name,
|
||||||
|
@ -83,7 +84,8 @@ export class VideoImportService {
|
||||||
commentsEnabled: video.commentsEnabled,
|
commentsEnabled: video.commentsEnabled,
|
||||||
thumbnailfile: video.thumbnailfile,
|
thumbnailfile: video.thumbnailfile,
|
||||||
previewfile: video.previewfile,
|
previewfile: video.previewfile,
|
||||||
scheduleUpdate
|
scheduleUpdate,
|
||||||
|
originallyPublishedAt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ export class VideoService implements VideosProvider {
|
||||||
const description = video.description || null
|
const description = video.description || null
|
||||||
const support = video.support || null
|
const support = video.support || null
|
||||||
const scheduleUpdate = video.scheduleUpdate || null
|
const scheduleUpdate = video.scheduleUpdate || null
|
||||||
|
const originallyPublishedAt = video.originallyPublishedAt || null
|
||||||
|
|
||||||
const body: VideoUpdate = {
|
const body: VideoUpdate = {
|
||||||
name: video.name,
|
name: video.name,
|
||||||
|
@ -97,7 +98,8 @@ export class VideoService implements VideosProvider {
|
||||||
commentsEnabled: video.commentsEnabled,
|
commentsEnabled: video.commentsEnabled,
|
||||||
thumbnailfile: video.thumbnailfile,
|
thumbnailfile: video.thumbnailfile,
|
||||||
previewfile: video.previewfile,
|
previewfile: video.previewfile,
|
||||||
scheduleUpdate
|
scheduleUpdate,
|
||||||
|
originallyPublishedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = objectToFormData(body)
|
const data = objectToFormData(body)
|
||||||
|
|
|
@ -114,6 +114,20 @@
|
||||||
</div>
|
</div>
|
||||||
</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
|
<my-peertube-checkbox
|
||||||
inputName="nsfw" formControlName="nsfw"
|
inputName="nsfw" formControlName="nsfw"
|
||||||
i18n-labelText labelText="This video contains mature or explicit content"
|
i18n-labelText labelText="This video contains mature or explicit content"
|
||||||
|
|
|
@ -45,6 +45,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
calendarLocale: any = {}
|
calendarLocale: any = {}
|
||||||
minScheduledDate = new Date()
|
minScheduledDate = new Date()
|
||||||
|
myYearRange = '1880:' + (new Date()).getFullYear()
|
||||||
|
|
||||||
calendarTimezone: string
|
calendarTimezone: string
|
||||||
calendarDateFormat: string
|
calendarDateFormat: string
|
||||||
|
@ -99,7 +100,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
|
||||||
thumbnailfile: null,
|
thumbnailfile: null,
|
||||||
previewfile: null,
|
previewfile: null,
|
||||||
support: this.videoValidatorsService.VIDEO_SUPPORT,
|
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(
|
this.formValidatorService.updateForm(
|
||||||
|
|
|
@ -188,7 +188,8 @@ async function addVideo (req: express.Request, res: express.Response) {
|
||||||
support: videoInfo.support,
|
support: videoInfo.support,
|
||||||
privacy: videoInfo.privacy,
|
privacy: videoInfo.privacy,
|
||||||
duration: videoPhysicalFile['duration'], // duration was added by a previous middleware
|
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)
|
const video = new VideoModel(videoData)
|
||||||
video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object
|
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.support !== undefined) videoInstance.set('support', videoInfoToUpdate.support)
|
||||||
if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description)
|
if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description)
|
||||||
if (videoInfoToUpdate.commentsEnabled !== undefined) videoInstance.set('commentsEnabled', videoInfoToUpdate.commentsEnabled)
|
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) {
|
if (videoInfoToUpdate.privacy !== undefined) {
|
||||||
const newPrivacy = parseInt(videoInfoToUpdate.privacy.toString(), 10)
|
const newPrivacy = parseInt(videoInfoToUpdate.privacy.toString(), 10)
|
||||||
videoInstance.set('privacy', newPrivacy)
|
videoInstance.set('privacy', newPrivacy)
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
VIDEO_STATES
|
VIDEO_STATES
|
||||||
} from '../../initializers'
|
} from '../../initializers'
|
||||||
import { VideoModel } from '../../models/video/video'
|
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 { VideoChannelModel } from '../../models/video/video-channel'
|
||||||
import { UserModel } from '../../models/account/user'
|
import { UserModel } from '../../models/account/user'
|
||||||
import * as magnetUtil from 'magnet-uri'
|
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) {
|
function isVideoFileInfoHashValid (value: string | null | undefined) {
|
||||||
return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH)
|
return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH)
|
||||||
}
|
}
|
||||||
|
@ -220,6 +224,7 @@ export {
|
||||||
isVideoTagsValid,
|
isVideoTagsValid,
|
||||||
isVideoFPSResolutionValid,
|
isVideoFPSResolutionValid,
|
||||||
isScheduleVideoUpdatePrivacyValid,
|
isScheduleVideoUpdatePrivacyValid,
|
||||||
|
isVideoOriginallyPublishedAtValid,
|
||||||
isVideoFile,
|
isVideoFile,
|
||||||
isVideoMagnetUriValid,
|
isVideoMagnetUriValid,
|
||||||
isVideoStateValid,
|
isVideoStateValid,
|
||||||
|
|
|
@ -14,6 +14,7 @@ import {
|
||||||
} from '../../../helpers/custom-validators/misc'
|
} from '../../../helpers/custom-validators/misc'
|
||||||
import {
|
import {
|
||||||
checkUserCanManageVideo,
|
checkUserCanManageVideo,
|
||||||
|
isVideoOriginallyPublishedAtValid,
|
||||||
isScheduleVideoUpdatePrivacyValid,
|
isScheduleVideoUpdatePrivacyValid,
|
||||||
isVideoCategoryValid,
|
isVideoCategoryValid,
|
||||||
isVideoChannelOfAccountExist,
|
isVideoChannelOfAccountExist,
|
||||||
|
@ -340,6 +341,10 @@ function getCommonVideoAttributes () {
|
||||||
.optional()
|
.optional()
|
||||||
.toBoolean()
|
.toBoolean()
|
||||||
.custom(isBooleanValid).withMessage('Should have comments enabled boolean'),
|
.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')
|
body('scheduleUpdate')
|
||||||
.optional()
|
.optional()
|
||||||
|
|
Loading…
Reference in New Issue