Enable video upload and edit
This commit is contained in:
parent
c80341655f
commit
1e74f19a21
8 changed files with 47 additions and 5 deletions
|
@ -16,6 +16,7 @@ export class VideoValidatorsService {
|
|||
readonly VIDEO_TAGS: BuildFormValidator
|
||||
readonly VIDEO_SUPPORT: BuildFormValidator
|
||||
readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator
|
||||
readonly VIDEO_ORIGINALLY_PUBLISHED_AT: BuildFormValidator
|
||||
|
||||
constructor (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: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ export class VideoImportService {
|
|||
const description = video.description || null
|
||||
const support = video.support || null
|
||||
const scheduleUpdate = video.scheduleUpdate || null
|
||||
const originallyPublishedAt = video.originallyPublishedAt || null
|
||||
|
||||
return {
|
||||
name: video.name,
|
||||
|
@ -83,7 +84,8 @@ export class VideoImportService {
|
|||
commentsEnabled: video.commentsEnabled,
|
||||
thumbnailfile: video.thumbnailfile,
|
||||
previewfile: video.previewfile,
|
||||
scheduleUpdate
|
||||
scheduleUpdate,
|
||||
originallyPublishedAt
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ export class VideoService implements VideosProvider {
|
|||
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,
|
||||
|
@ -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)
|
||||
|
|
|
@ -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-checkbox
|
||||
inputName="nsfw" formControlName="nsfw"
|
||||
i18n-labelText labelText="This video contains mature or explicit content"
|
||||
|
|
|
@ -45,6 +45,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
|
|||
|
||||
calendarLocale: any = {}
|
||||
minScheduledDate = new Date()
|
||||
myYearRange = '1880:' + (new Date()).getFullYear()
|
||||
|
||||
calendarTimezone: string
|
||||
calendarDateFormat: 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(
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue