From 4bbc373f134ecbf53f0198277663a25b26a19cc8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Jan 2018 17:37:49 +0100 Subject: Add reject processing for activitypub --- server/helpers/custom-validators/activitypub/activity.ts | 10 +++++++++- server/helpers/custom-validators/activitypub/actor.ts | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'server/helpers/custom-validators') diff --git a/server/helpers/custom-validators/activitypub/activity.ts b/server/helpers/custom-validators/activitypub/activity.ts index 577cf4b52..632f14223 100644 --- a/server/helpers/custom-validators/activitypub/activity.ts +++ b/server/helpers/custom-validators/activitypub/activity.ts @@ -1,6 +1,9 @@ import * as validator from 'validator' import { Activity, ActivityType } from '../../../../shared/models/activitypub' -import { isActorAcceptActivityValid, isActorDeleteActivityValid, isActorFollowActivityValid, isActorUpdateActivityValid } from './actor' +import { + isActorAcceptActivityValid, isActorDeleteActivityValid, isActorFollowActivityValid, isActorRejectActivityValid, + isActorUpdateActivityValid +} from './actor' import { isAnnounceActivityValid } from './announce' import { isActivityPubUrlValid } from './misc' import { isDislikeActivityValid, isLikeActivityValid } from './rate' @@ -33,6 +36,7 @@ const activityCheckers: { [ P in ActivityType ]: (activity: Activity) => boolean Delete: checkDeleteActivity, Follow: checkFollowActivity, Accept: checkAcceptActivity, + Reject: checkRejectActivity, Announce: checkAnnounceActivity, Undo: checkUndoActivity, Like: checkLikeActivity @@ -82,6 +86,10 @@ function checkAcceptActivity (activity: any) { return isActorAcceptActivityValid(activity) } +function checkRejectActivity (activity: any) { + return isActorRejectActivityValid(activity) +} + function checkAnnounceActivity (activity: any) { return isAnnounceActivityValid(activity) } diff --git a/server/helpers/custom-validators/activitypub/actor.ts b/server/helpers/custom-validators/activitypub/actor.ts index e1a4b5b8f..df0edc30e 100644 --- a/server/helpers/custom-validators/activitypub/actor.ts +++ b/server/helpers/custom-validators/activitypub/actor.ts @@ -78,6 +78,10 @@ function isActorAcceptActivityValid (activity: any) { return isBaseActivityValid(activity, 'Accept') } +function isActorRejectActivityValid (activity: any) { + return isBaseActivityValid(activity, 'Reject') +} + function isActorUpdateActivityValid (activity: any) { return isBaseActivityValid(activity, 'Update') && isActorObjectValid(activity.object) @@ -97,6 +101,7 @@ export { isActorFollowersCountValid, isActorFollowActivityValid, isActorAcceptActivityValid, + isActorRejectActivityValid, isActorDeleteActivityValid, isActorUpdateActivityValid } -- cgit v1.2.3