From 9d3ef9fe052ed29bd67566754cb28662bd122234 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 23 Apr 2018 14:39:52 +0200 Subject: Use ISO 639 for languages --- server/helpers/custom-validators/activitypub/videos.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'server/helpers/custom-validators/activitypub') diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index d8986b2a0..8ec7df49a 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts @@ -49,9 +49,9 @@ function isVideoTorrentObjectValid (video: any) { isActivityPubVideoDurationValid(video.duration) && isUUIDValid(video.uuid) && setValidRemoteTags(video) && - (!video.category || isRemoteIdentifierValid(video.category)) && - (!video.licence || isRemoteIdentifierValid(video.licence)) && - (!video.language || isRemoteIdentifierValid(video.language)) && + (!video.category || isRemoteNumberIdentifierValid(video.category)) && + (!video.licence || isRemoteNumberIdentifierValid(video.licence)) && + (!video.language || isRemoteStringIdentifierValid(video.language)) && isVideoViewsValid(video.views) && isBooleanValid(video.sensitive) && isBooleanValid(video.commentsEnabled) && @@ -72,6 +72,7 @@ export { isVideoTorrentCreateActivityValid, isVideoTorrentUpdateActivityValid, isVideoTorrentDeleteActivityValid, + isRemoteStringIdentifierValid, isVideoFlagValid, isVideoTorrentObjectValid } @@ -89,10 +90,14 @@ function setValidRemoteTags (video: any) { return true } -function isRemoteIdentifierValid (data: any) { +function isRemoteNumberIdentifierValid (data: any) { return validator.isInt(data.identifier, { min: 0 }) } +function isRemoteStringIdentifierValid (data: any) { + return typeof data.identifier === 'string' +} + function isRemoteVideoContentValid (mediaType: string, content: string) { return mediaType === 'text/markdown' && isVideoTruncatedDescriptionValid(content) } -- cgit v1.2.3