diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-23 14:19:55 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:53 +0100 |
commit | 0032ebe94aa83fab761c7de3ceb6210ac4532824 (patch) | |
tree | 3ea407d7ea6de4c7f7bc66caba7e23c0cc4036e3 /server/helpers/custom-validators/activitypub/activity.ts | |
parent | d52eb8f656242c7e34afdb2dee681861fb9bce35 (diff) | |
download | PeerTube-0032ebe94aa83fab761c7de3ceb6210ac4532824.tar.gz PeerTube-0032ebe94aa83fab761c7de3ceb6210ac4532824.tar.zst PeerTube-0032ebe94aa83fab761c7de3ceb6210ac4532824.zip |
Federate likes/dislikes
Diffstat (limited to 'server/helpers/custom-validators/activitypub/activity.ts')
-rw-r--r-- | server/helpers/custom-validators/activitypub/activity.ts | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/server/helpers/custom-validators/activitypub/activity.ts b/server/helpers/custom-validators/activitypub/activity.ts index 66e557d39..3a0e8197c 100644 --- a/server/helpers/custom-validators/activitypub/activity.ts +++ b/server/helpers/custom-validators/activitypub/activity.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import * as validator from 'validator' | 1 | import * as validator from 'validator' |
2 | import { Activity, ActivityType } from '../../../../shared/models/activitypub/activity' | 2 | import { Activity, ActivityType } from '../../../../shared/models/activitypub/activity' |
3 | import { isAccountAcceptActivityValid, isAccountDeleteActivityValid, isAccountFollowActivityValid } from './account' | 3 | import { isAccountAcceptActivityValid, isAccountDeleteActivityValid, isAccountFollowActivityValid } from './account' |
4 | import { isAnnounceValid } from './announce' | 4 | import { isAnnounceActivityValid } from './announce' |
5 | import { isActivityPubUrlValid } from './misc' | 5 | import { isActivityPubUrlValid } from './misc' |
6 | import { isUndoValid } from './undo' | 6 | import { isUndoActivityValid } from './undo' |
7 | import { isVideoChannelCreateActivityValid, isVideoChannelDeleteActivityValid, isVideoChannelUpdateActivityValid } from './video-channels' | 7 | import { isVideoChannelCreateActivityValid, isVideoChannelDeleteActivityValid, isVideoChannelUpdateActivityValid } from './video-channels' |
8 | import { | 8 | import { |
9 | isVideoFlagValid, | 9 | isVideoFlagValid, |
@@ -12,6 +12,7 @@ import { | |||
12 | isVideoTorrentUpdateActivityValid | 12 | isVideoTorrentUpdateActivityValid |
13 | } from './videos' | 13 | } from './videos' |
14 | import { isViewActivityValid } from './view' | 14 | import { isViewActivityValid } from './view' |
15 | import { isDislikeActivityValid, isLikeActivityValid } from './rate' | ||
15 | 16 | ||
16 | function isRootActivityValid (activity: any) { | 17 | function isRootActivityValid (activity: any) { |
17 | return Array.isArray(activity['@context']) && | 18 | return Array.isArray(activity['@context']) && |
@@ -34,7 +35,8 @@ const activityCheckers: { [ P in ActivityType ]: (activity: Activity) => boolean | |||
34 | Follow: checkFollowActivity, | 35 | Follow: checkFollowActivity, |
35 | Accept: checkAcceptActivity, | 36 | Accept: checkAcceptActivity, |
36 | Announce: checkAnnounceActivity, | 37 | Announce: checkAnnounceActivity, |
37 | Undo: checkUndoActivity | 38 | Undo: checkUndoActivity, |
39 | Like: checkLikeActivity | ||
38 | } | 40 | } |
39 | 41 | ||
40 | function isActivityValid (activity: any) { | 42 | function isActivityValid (activity: any) { |
@@ -55,9 +57,10 @@ export { | |||
55 | // --------------------------------------------------------------------------- | 57 | // --------------------------------------------------------------------------- |
56 | 58 | ||
57 | function checkCreateActivity (activity: any) { | 59 | function checkCreateActivity (activity: any) { |
58 | return isVideoChannelCreateActivityValid(activity) || | 60 | return isViewActivityValid(activity) || |
59 | isVideoFlagValid(activity) || | 61 | isDislikeActivityValid(activity) || |
60 | isViewActivityValid(activity) | 62 | isVideoChannelCreateActivityValid(activity) || |
63 | isVideoFlagValid(activity) | ||
61 | } | 64 | } |
62 | 65 | ||
63 | function checkAddActivity (activity: any) { | 66 | function checkAddActivity (activity: any) { |
@@ -84,9 +87,13 @@ function checkAcceptActivity (activity: any) { | |||
84 | } | 87 | } |
85 | 88 | ||
86 | function checkAnnounceActivity (activity: any) { | 89 | function checkAnnounceActivity (activity: any) { |
87 | return isAnnounceValid(activity) | 90 | return isAnnounceActivityValid(activity) |
88 | } | 91 | } |
89 | 92 | ||
90 | function checkUndoActivity (activity: any) { | 93 | function checkUndoActivity (activity: any) { |
91 | return isUndoValid(activity) | 94 | return isUndoActivityValid(activity) |
95 | } | ||
96 | |||
97 | function checkLikeActivity (activity: any) { | ||
98 | return isLikeActivityValid(activity) | ||
92 | } | 99 | } |