1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Continue activitypub

This commit is contained in:
Chocobozzz 2017-11-10 14:34:45 +01:00
parent e4f97babf7
commit 0d0e8dd090
No known key found for this signature in database
GPG key ID: 583A612D890159BE
27 changed files with 1039 additions and 1086 deletions

View file

@ -73,19 +73,26 @@ function isVideoDescriptionValid (value: string) {
}
function isVideoDurationValid (value: string) {
return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION)
// https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
return exists(value) &&
typeof value === 'string' &&
value.startsWith('PT') &&
value.endsWith('S') &&
validator.isInt(value.replace(/[^0-9]+/, ''), VIDEOS_CONSTRAINTS_FIELDS.DURATION)
}
function isVideoNameValid (value: string) {
return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME)
}
function isVideoTagValid (tag: string) {
return exists(tag) && validator.isLength(tag, VIDEOS_CONSTRAINTS_FIELDS.TAG)
}
function isVideoTagsValid (tags: string[]) {
return isArray(tags) &&
validator.isInt(tags.length.toString(), VIDEOS_CONSTRAINTS_FIELDS.TAGS) &&
tags.every(tag => {
return exists(tag) && validator.isLength(tag, VIDEOS_CONSTRAINTS_FIELDS.TAG)
})
tags.every(tag => isVideoTagValid(tag))
}
function isVideoThumbnailValid (value: string) {
@ -209,6 +216,7 @@ export {
isRemoteVideoPrivacyValid,
isVideoFileResolutionValid,
checkVideoExists,
isVideoTagValid,
isRemoteVideoCategoryValid,
isRemoteVideoLicenceValid,
isRemoteVideoLanguageValid