aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/activitypub/videos.ts14
1 files changed, 12 insertions, 2 deletions
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 {
13import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc' 13import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc'
14import { VideoState } from '../../../../shared/models/videos' 14import { VideoState } from '../../../../shared/models/videos'
15import { logger } from '@server/helpers/logger' 15import { logger } from '@server/helpers/logger'
16import { ActivityVideoFileMetadataObject } from '@shared/models'
16 17
17function sanitizeAndCheckVideoTorrentUpdateActivity (activity: any) { 18function sanitizeAndCheckVideoTorrentUpdateActivity (activity: any) {
18 return isBaseActivityValid(activity, 'Update') && 19 return isBaseActivityValid(activity, 'Update') &&
@@ -104,7 +105,15 @@ function isRemoteVideoUrlValid (url: any) {
104 (url.mediaType || url.mimeType) === 'application/x-mpegURL' && 105 (url.mediaType || url.mimeType) === 'application/x-mpegURL' &&
105 isActivityPubUrlValid(url.href) && 106 isActivityPubUrlValid(url.href) &&
106 isArray(url.tag) 107 isArray(url.tag)
107 ) 108 ) ||
109 isAPVideoFileMetadataObject(url)
110}
111
112function isAPVideoFileMetadataObject (url: any): url is ActivityVideoFileMetadataObject {
113 return url &&
114 url.type === 'Link' &&
115 url.mediaType === 'application/json' &&
116 isArray(url.rel) && url.rel.includes('metadata')
108} 117}
109 118
110// --------------------------------------------------------------------------- 119// ---------------------------------------------------------------------------
@@ -113,7 +122,8 @@ export {
113 sanitizeAndCheckVideoTorrentUpdateActivity, 122 sanitizeAndCheckVideoTorrentUpdateActivity,
114 isRemoteStringIdentifierValid, 123 isRemoteStringIdentifierValid,
115 sanitizeAndCheckVideoTorrentObject, 124 sanitizeAndCheckVideoTorrentObject,
116 isRemoteVideoUrlValid 125 isRemoteVideoUrlValid,
126 isAPVideoFileMetadataObject
117} 127}
118 128
119// --------------------------------------------------------------------------- 129// ---------------------------------------------------------------------------