From 40ff57078e15d5b86ee6b71e198b95d3feb78eaf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 22 Nov 2017 16:25:03 +0100 Subject: Federate video views --- server/helpers/custom-validators/activitypub/activity.ts | 4 +++- server/helpers/custom-validators/activitypub/index.ts | 1 + server/helpers/custom-validators/activitypub/videos.ts | 2 +- server/helpers/custom-validators/activitypub/view.ts | 13 +++++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 server/helpers/custom-validators/activitypub/view.ts (limited to 'server/helpers') diff --git a/server/helpers/custom-validators/activitypub/activity.ts b/server/helpers/custom-validators/activitypub/activity.ts index 9305e092c..66e557d39 100644 --- a/server/helpers/custom-validators/activitypub/activity.ts +++ b/server/helpers/custom-validators/activitypub/activity.ts @@ -11,6 +11,7 @@ import { isVideoTorrentDeleteActivityValid, isVideoTorrentUpdateActivityValid } from './videos' +import { isViewActivityValid } from './view' function isRootActivityValid (activity: any) { return Array.isArray(activity['@context']) && @@ -55,7 +56,8 @@ export { function checkCreateActivity (activity: any) { return isVideoChannelCreateActivityValid(activity) || - isVideoFlagValid(activity) + isVideoFlagValid(activity) || + isViewActivityValid(activity) } function checkAddActivity (activity: any) { diff --git a/server/helpers/custom-validators/activitypub/index.ts b/server/helpers/custom-validators/activitypub/index.ts index 6685b269f..f8dfae4ff 100644 --- a/server/helpers/custom-validators/activitypub/index.ts +++ b/server/helpers/custom-validators/activitypub/index.ts @@ -5,3 +5,4 @@ export * from './signature' export * from './undo' export * from './video-channels' export * from './videos' +export * from './view' diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index faeedd3df..55e79c4e8 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts @@ -52,7 +52,7 @@ function isVideoTorrentObjectValid (video: any) { setValidRemoteTags(video) && isRemoteIdentifierValid(video.category) && isRemoteIdentifierValid(video.licence) && - isRemoteIdentifierValid(video.language) && + (!video.language || isRemoteIdentifierValid(video.language)) && isVideoViewsValid(video.views) && isVideoNSFWValid(video.nsfw) && isDateValid(video.published) && diff --git a/server/helpers/custom-validators/activitypub/view.ts b/server/helpers/custom-validators/activitypub/view.ts new file mode 100644 index 000000000..7a3aca6f5 --- /dev/null +++ b/server/helpers/custom-validators/activitypub/view.ts @@ -0,0 +1,13 @@ +import { isActivityPubUrlValid, isBaseActivityValid } from './misc' + +function isViewActivityValid (activity: any) { + return isBaseActivityValid(activity, 'Create') && + activity.object.type === 'View' && + isActivityPubUrlValid(activity.object.actor) && + isActivityPubUrlValid(activity.object.object) +} +// --------------------------------------------------------------------------- + +export { + isViewActivityValid +} -- cgit v1.2.3