diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-03 16:38:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-03 16:38:50 +0100 |
commit | 265ba139ebf56bbdc1c65f6ea4f367774c691fc0 (patch) | |
tree | c7c52d1ae48a35b8f9aa06a9fa2335a6ba502fd1 /server/helpers/custom-validators | |
parent | 9bce811268cd74b402176ae9fcd8b77ac887576e (diff) | |
download | PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.tar.gz PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.tar.zst PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.zip |
Send account activitypub update events
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/activitypub/activity.ts | 5 | ||||
-rw-r--r-- | server/helpers/custom-validators/activitypub/actor.ts | 37 |
2 files changed, 24 insertions, 18 deletions
diff --git a/server/helpers/custom-validators/activitypub/activity.ts b/server/helpers/custom-validators/activitypub/activity.ts index fbdde10ad..856c87f2c 100644 --- a/server/helpers/custom-validators/activitypub/activity.ts +++ b/server/helpers/custom-validators/activitypub/activity.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as validator from 'validator' | 1 | import * as validator from 'validator' |
2 | import { Activity, ActivityType } from '../../../../shared/models/activitypub' | 2 | import { Activity, ActivityType } from '../../../../shared/models/activitypub' |
3 | import { isActorAcceptActivityValid, isActorDeleteActivityValid, isActorFollowActivityValid } from './actor' | 3 | import { isActorAcceptActivityValid, isActorDeleteActivityValid, isActorFollowActivityValid, isActorUpdateActivityValid } from './actor' |
4 | import { isAnnounceActivityValid } from './announce' | 4 | import { isAnnounceActivityValid } from './announce' |
5 | import { isActivityPubUrlValid } from './misc' | 5 | import { isActivityPubUrlValid } from './misc' |
6 | import { isDislikeActivityValid, isLikeActivityValid } from './rate' | 6 | import { isDislikeActivityValid, isLikeActivityValid } from './rate' |
@@ -64,7 +64,8 @@ function checkCreateActivity (activity: any) { | |||
64 | } | 64 | } |
65 | 65 | ||
66 | function checkUpdateActivity (activity: any) { | 66 | function checkUpdateActivity (activity: any) { |
67 | return isVideoTorrentUpdateActivityValid(activity) | 67 | return isVideoTorrentUpdateActivityValid(activity) || |
68 | isActorUpdateActivityValid(activity) | ||
68 | } | 69 | } |
69 | 70 | ||
70 | function checkDeleteActivity (activity: any) { | 71 | function checkDeleteActivity (activity: any) { |
diff --git a/server/helpers/custom-validators/activitypub/actor.ts b/server/helpers/custom-validators/activitypub/actor.ts index 700e06007..8820bb2a4 100644 --- a/server/helpers/custom-validators/activitypub/actor.ts +++ b/server/helpers/custom-validators/activitypub/actor.ts | |||
@@ -45,22 +45,22 @@ function isActorPrivateKeyValid (privateKey: string) { | |||
45 | validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY) | 45 | validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY) |
46 | } | 46 | } |
47 | 47 | ||
48 | function isRemoteActorValid (remoteActor: any) { | 48 | function isActorObjectValid (actor: any) { |
49 | return exists(remoteActor) && | 49 | return exists(actor) && |
50 | isActivityPubUrlValid(remoteActor.id) && | 50 | isActivityPubUrlValid(actor.id) && |
51 | isActorTypeValid(remoteActor.type) && | 51 | isActorTypeValid(actor.type) && |
52 | isActivityPubUrlValid(remoteActor.following) && | 52 | isActivityPubUrlValid(actor.following) && |
53 | isActivityPubUrlValid(remoteActor.followers) && | 53 | isActivityPubUrlValid(actor.followers) && |
54 | isActivityPubUrlValid(remoteActor.inbox) && | 54 | isActivityPubUrlValid(actor.inbox) && |
55 | isActivityPubUrlValid(remoteActor.outbox) && | 55 | isActivityPubUrlValid(actor.outbox) && |
56 | isActorPreferredUsernameValid(remoteActor.preferredUsername) && | 56 | isActorPreferredUsernameValid(actor.preferredUsername) && |
57 | isActivityPubUrlValid(remoteActor.url) && | 57 | isActivityPubUrlValid(actor.url) && |
58 | isActorPublicKeyObjectValid(remoteActor.publicKey) && | 58 | isActorPublicKeyObjectValid(actor.publicKey) && |
59 | isActorEndpointsObjectValid(remoteActor.endpoints) && | 59 | isActorEndpointsObjectValid(actor.endpoints) && |
60 | setValidAttributedTo(remoteActor) && | 60 | setValidAttributedTo(actor) && |
61 | // If this is not an account, it should be attributed to an account | 61 | // If this is not an account, it should be attributed to an account |
62 | // In PeerTube we use this to attach a video channel to a specific account | 62 | // In PeerTube we use this to attach a video channel to a specific account |
63 | (remoteActor.type === 'Person' || remoteActor.attributedTo.length !== 0) | 63 | (actor.type === 'Person' || actor.attributedTo.length !== 0) |
64 | } | 64 | } |
65 | 65 | ||
66 | function isActorFollowingCountValid (value: string) { | 66 | function isActorFollowingCountValid (value: string) { |
@@ -84,6 +84,11 @@ function isActorAcceptActivityValid (activity: any) { | |||
84 | return isBaseActivityValid(activity, 'Accept') | 84 | return isBaseActivityValid(activity, 'Accept') |
85 | } | 85 | } |
86 | 86 | ||
87 | function isActorUpdateActivityValid (activity: any) { | ||
88 | return isBaseActivityValid(activity, 'Update') && | ||
89 | isActorObjectValid(activity.object) | ||
90 | } | ||
91 | |||
87 | // --------------------------------------------------------------------------- | 92 | // --------------------------------------------------------------------------- |
88 | 93 | ||
89 | export { | 94 | export { |
@@ -93,11 +98,11 @@ export { | |||
93 | isActorPublicKeyValid, | 98 | isActorPublicKeyValid, |
94 | isActorPreferredUsernameValid, | 99 | isActorPreferredUsernameValid, |
95 | isActorPrivateKeyValid, | 100 | isActorPrivateKeyValid, |
96 | isRemoteActorValid, | 101 | isActorObjectValid, |
97 | isActorFollowingCountValid, | 102 | isActorFollowingCountValid, |
98 | isActorFollowersCountValid, | 103 | isActorFollowersCountValid, |
99 | isActorFollowActivityValid, | 104 | isActorFollowActivityValid, |
100 | isActorAcceptActivityValid, | 105 | isActorAcceptActivityValid, |
101 | isActorDeleteActivityValid, | 106 | isActorDeleteActivityValid, |
102 | isActorNameValid | 107 | isActorUpdateActivityValid |
103 | } | 108 | } |