aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/activitypub/activity.ts5
-rw-r--r--server/helpers/custom-validators/activitypub/actor.ts37
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 @@
1import * as validator from 'validator' 1import * as validator from 'validator'
2import { Activity, ActivityType } from '../../../../shared/models/activitypub' 2import { Activity, ActivityType } from '../../../../shared/models/activitypub'
3import { isActorAcceptActivityValid, isActorDeleteActivityValid, isActorFollowActivityValid } from './actor' 3import { isActorAcceptActivityValid, isActorDeleteActivityValid, isActorFollowActivityValid, isActorUpdateActivityValid } from './actor'
4import { isAnnounceActivityValid } from './announce' 4import { isAnnounceActivityValid } from './announce'
5import { isActivityPubUrlValid } from './misc' 5import { isActivityPubUrlValid } from './misc'
6import { isDislikeActivityValid, isLikeActivityValid } from './rate' 6import { isDislikeActivityValid, isLikeActivityValid } from './rate'
@@ -64,7 +64,8 @@ function checkCreateActivity (activity: any) {
64} 64}
65 65
66function checkUpdateActivity (activity: any) { 66function checkUpdateActivity (activity: any) {
67 return isVideoTorrentUpdateActivityValid(activity) 67 return isVideoTorrentUpdateActivityValid(activity) ||
68 isActorUpdateActivityValid(activity)
68} 69}
69 70
70function checkDeleteActivity (activity: any) { 71function 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
48function isRemoteActorValid (remoteActor: any) { 48function 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
66function isActorFollowingCountValid (value: string) { 66function 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
87function isActorUpdateActivityValid (activity: any) {
88 return isBaseActivityValid(activity, 'Update') &&
89 isActorObjectValid(activity.object)
90}
91
87// --------------------------------------------------------------------------- 92// ---------------------------------------------------------------------------
88 93
89export { 94export {
@@ -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}