From 7b81edc854902a536083298472bf92bb6726edcf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 10 Mar 2020 14:49:02 +0100 Subject: Video file metadata PR cleanup --- server/helpers/custom-validators/activitypub/videos.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'server/helpers/custom-validators') diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index af8c8a0c8..876cc7f50 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts @@ -13,6 +13,7 @@ import { import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc' import { VideoState } from '../../../../shared/models/videos' import { logger } from '@server/helpers/logger' +import { ActivityVideoFileMetadataObject } from '@shared/models' function sanitizeAndCheckVideoTorrentUpdateActivity (activity: any) { return isBaseActivityValid(activity, 'Update') && @@ -104,7 +105,15 @@ function isRemoteVideoUrlValid (url: any) { (url.mediaType || url.mimeType) === 'application/x-mpegURL' && isActivityPubUrlValid(url.href) && isArray(url.tag) - ) + ) || + isAPVideoFileMetadataObject(url) +} + +function isAPVideoFileMetadataObject (url: any): url is ActivityVideoFileMetadataObject { + return url && + url.type === 'Link' && + url.mediaType === 'application/json' && + isArray(url.rel) && url.rel.includes('metadata') } // --------------------------------------------------------------------------- @@ -113,7 +122,8 @@ export { sanitizeAndCheckVideoTorrentUpdateActivity, isRemoteStringIdentifierValid, sanitizeAndCheckVideoTorrentObject, - isRemoteVideoUrlValid + isRemoteVideoUrlValid, + isAPVideoFileMetadataObject } // --------------------------------------------------------------------------- -- cgit v1.2.3