diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-22 16:25:03 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:53 +0100 |
commit | 40ff57078e15d5b86ee6b71e198b95d3feb78eaf (patch) | |
tree | 88031d4eac6a26597e8a1f2fc63674664e3eae26 /server/helpers | |
parent | c46edbc2f6ca310b2f0331f979ac6caf27f6eb92 (diff) | |
download | PeerTube-40ff57078e15d5b86ee6b71e198b95d3feb78eaf.tar.gz PeerTube-40ff57078e15d5b86ee6b71e198b95d3feb78eaf.tar.zst PeerTube-40ff57078e15d5b86ee6b71e198b95d3feb78eaf.zip |
Federate video views
Diffstat (limited to 'server/helpers')
4 files changed, 18 insertions, 2 deletions
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 { | |||
11 | isVideoTorrentDeleteActivityValid, | 11 | isVideoTorrentDeleteActivityValid, |
12 | isVideoTorrentUpdateActivityValid | 12 | isVideoTorrentUpdateActivityValid |
13 | } from './videos' | 13 | } from './videos' |
14 | import { isViewActivityValid } from './view' | ||
14 | 15 | ||
15 | function isRootActivityValid (activity: any) { | 16 | function isRootActivityValid (activity: any) { |
16 | return Array.isArray(activity['@context']) && | 17 | return Array.isArray(activity['@context']) && |
@@ -55,7 +56,8 @@ export { | |||
55 | 56 | ||
56 | function checkCreateActivity (activity: any) { | 57 | function checkCreateActivity (activity: any) { |
57 | return isVideoChannelCreateActivityValid(activity) || | 58 | return isVideoChannelCreateActivityValid(activity) || |
58 | isVideoFlagValid(activity) | 59 | isVideoFlagValid(activity) || |
60 | isViewActivityValid(activity) | ||
59 | } | 61 | } |
60 | 62 | ||
61 | function checkAddActivity (activity: any) { | 63 | 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' | |||
5 | export * from './undo' | 5 | export * from './undo' |
6 | export * from './video-channels' | 6 | export * from './video-channels' |
7 | export * from './videos' | 7 | export * from './videos' |
8 | 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) { | |||
52 | setValidRemoteTags(video) && | 52 | setValidRemoteTags(video) && |
53 | isRemoteIdentifierValid(video.category) && | 53 | isRemoteIdentifierValid(video.category) && |
54 | isRemoteIdentifierValid(video.licence) && | 54 | isRemoteIdentifierValid(video.licence) && |
55 | isRemoteIdentifierValid(video.language) && | 55 | (!video.language || isRemoteIdentifierValid(video.language)) && |
56 | isVideoViewsValid(video.views) && | 56 | isVideoViewsValid(video.views) && |
57 | isVideoNSFWValid(video.nsfw) && | 57 | isVideoNSFWValid(video.nsfw) && |
58 | isDateValid(video.published) && | 58 | 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 @@ | |||
1 | import { isActivityPubUrlValid, isBaseActivityValid } from './misc' | ||
2 | |||
3 | function isViewActivityValid (activity: any) { | ||
4 | return isBaseActivityValid(activity, 'Create') && | ||
5 | activity.object.type === 'View' && | ||
6 | isActivityPubUrlValid(activity.object.actor) && | ||
7 | isActivityPubUrlValid(activity.object.object) | ||
8 | } | ||
9 | // --------------------------------------------------------------------------- | ||
10 | |||
11 | export { | ||
12 | isViewActivityValid | ||
13 | } | ||