diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-15 17:56:21 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | d846501818c2d29e66e6fd141789cb04fd55a437 (patch) | |
tree | 9b807a84459edd400fd36325c49c4adfbd6c4fd2 /server/helpers/custom-validators | |
parent | 8e10cf1a5a438a00e5f7e0691cb830769867cffc (diff) | |
download | PeerTube-d846501818c2d29e66e6fd141789cb04fd55a437.tar.gz PeerTube-d846501818c2d29e66e6fd141789cb04fd55a437.tar.zst PeerTube-d846501818c2d29e66e6fd141789cb04fd55a437.zip |
Handle announces in inbox
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/activitypub/activity.ts | 8 | ||||
-rw-r--r-- | server/helpers/custom-validators/activitypub/videos.ts | 24 |
2 files changed, 29 insertions, 3 deletions
diff --git a/server/helpers/custom-validators/activitypub/activity.ts b/server/helpers/custom-validators/activitypub/activity.ts index b5ba0f7af..08e5ae0aa 100644 --- a/server/helpers/custom-validators/activitypub/activity.ts +++ b/server/helpers/custom-validators/activitypub/activity.ts | |||
@@ -2,9 +2,12 @@ import * as validator from 'validator' | |||
2 | import { isAccountAcceptActivityValid, isAccountDeleteActivityValid, isAccountFollowActivityValid } from './account' | 2 | import { isAccountAcceptActivityValid, isAccountDeleteActivityValid, isAccountFollowActivityValid } from './account' |
3 | import { isActivityPubUrlValid } from './misc' | 3 | import { isActivityPubUrlValid } from './misc' |
4 | import { | 4 | import { |
5 | isVideoAnnounceValid, | ||
6 | isVideoChannelAnnounceValid, | ||
5 | isVideoChannelCreateActivityValid, | 7 | isVideoChannelCreateActivityValid, |
6 | isVideoChannelDeleteActivityValid, | 8 | isVideoChannelDeleteActivityValid, |
7 | isVideoChannelUpdateActivityValid, | 9 | isVideoChannelUpdateActivityValid, |
10 | isVideoFlagValid, | ||
8 | isVideoTorrentAddActivityValid, | 11 | isVideoTorrentAddActivityValid, |
9 | isVideoTorrentDeleteActivityValid, | 12 | isVideoTorrentDeleteActivityValid, |
10 | isVideoTorrentUpdateActivityValid | 13 | isVideoTorrentUpdateActivityValid |
@@ -32,7 +35,10 @@ function isActivityValid (activity: any) { | |||
32 | isVideoChannelDeleteActivityValid(activity) || | 35 | isVideoChannelDeleteActivityValid(activity) || |
33 | isAccountDeleteActivityValid(activity) || | 36 | isAccountDeleteActivityValid(activity) || |
34 | isAccountFollowActivityValid(activity) || | 37 | isAccountFollowActivityValid(activity) || |
35 | isAccountAcceptActivityValid(activity) | 38 | isAccountAcceptActivityValid(activity) || |
39 | isVideoFlagValid(activity) || | ||
40 | isVideoAnnounceValid(activity) || | ||
41 | isVideoChannelAnnounceValid(activity) | ||
36 | } | 42 | } |
37 | 43 | ||
38 | // --------------------------------------------------------------------------- | 44 | // --------------------------------------------------------------------------- |
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index a46757397..9ddacd601 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts | |||
@@ -3,6 +3,7 @@ import { ACTIVITY_PUB } from '../../../initializers' | |||
3 | import { exists, isDateValid, isUUIDValid } from '../misc' | 3 | import { exists, isDateValid, isUUIDValid } from '../misc' |
4 | import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../video-channels' | 4 | import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../video-channels' |
5 | import { | 5 | import { |
6 | isVideoAbuseReasonValid, | ||
6 | isVideoDurationValid, | 7 | isVideoDurationValid, |
7 | isVideoNameValid, | 8 | isVideoNameValid, |
8 | isVideoNSFWValid, | 9 | isVideoNSFWValid, |
@@ -11,7 +12,7 @@ import { | |||
11 | isVideoUrlValid, | 12 | isVideoUrlValid, |
12 | isVideoViewsValid | 13 | isVideoViewsValid |
13 | } from '../videos' | 14 | } from '../videos' |
14 | import { isBaseActivityValid } from './misc' | 15 | import { isActivityPubUrlValid, isBaseActivityValid } from './misc' |
15 | 16 | ||
16 | function isVideoTorrentAddActivityValid (activity: any) { | 17 | function isVideoTorrentAddActivityValid (activity: any) { |
17 | return isBaseActivityValid(activity, 'Add') && | 18 | return isBaseActivityValid(activity, 'Add') && |
@@ -54,6 +55,22 @@ function isVideoTorrentObjectValid (video: any) { | |||
54 | setValidRemoteVideoUrls(video.url) | 55 | setValidRemoteVideoUrls(video.url) |
55 | } | 56 | } |
56 | 57 | ||
58 | function isVideoFlagValid (activity: any) { | ||
59 | return isBaseActivityValid(activity, 'Flag') && | ||
60 | isVideoAbuseReasonValid(activity.content) && | ||
61 | isActivityPubUrlValid(activity.object) | ||
62 | } | ||
63 | |||
64 | function isVideoAnnounceValid (activity: any) { | ||
65 | return isBaseActivityValid(activity, 'Announce') && | ||
66 | isVideoTorrentObjectValid(activity.object) | ||
67 | } | ||
68 | |||
69 | function isVideoChannelAnnounceValid (activity: any) { | ||
70 | return isBaseActivityValid(activity, 'Announce') && | ||
71 | isVideoChannelObjectValid(activity.object) | ||
72 | } | ||
73 | |||
57 | function isVideoChannelCreateActivityValid (activity: any) { | 74 | function isVideoChannelCreateActivityValid (activity: any) { |
58 | return isBaseActivityValid(activity, 'Create') && | 75 | return isBaseActivityValid(activity, 'Create') && |
59 | isVideoChannelObjectValid(activity.object) | 76 | isVideoChannelObjectValid(activity.object) |
@@ -83,7 +100,10 @@ export { | |||
83 | isVideoTorrentUpdateActivityValid, | 100 | isVideoTorrentUpdateActivityValid, |
84 | isVideoChannelUpdateActivityValid, | 101 | isVideoChannelUpdateActivityValid, |
85 | isVideoChannelDeleteActivityValid, | 102 | isVideoChannelDeleteActivityValid, |
86 | isVideoTorrentDeleteActivityValid | 103 | isVideoTorrentDeleteActivityValid, |
104 | isVideoFlagValid, | ||
105 | isVideoAnnounceValid, | ||
106 | isVideoChannelAnnounceValid | ||
87 | } | 107 | } |
88 | 108 | ||
89 | // --------------------------------------------------------------------------- | 109 | // --------------------------------------------------------------------------- |