aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/process/process-reject.ts32
-rw-r--r--server/lib/activitypub/process/process.ts2
2 files changed, 34 insertions, 0 deletions
diff --git a/server/lib/activitypub/process/process-reject.ts b/server/lib/activitypub/process/process-reject.ts
new file mode 100644
index 000000000..b2de28d79
--- /dev/null
+++ b/server/lib/activitypub/process/process-reject.ts
@@ -0,0 +1,32 @@
1import { ActivityReject } from '../../../../shared/models/activitypub/activity'
2import { sequelizeTypescript } from '../../../initializers'
3import { ActorModel } from '../../../models/activitypub/actor'
4import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
5
6async function processRejectActivity (activity: ActivityReject, inboxActor?: ActorModel) {
7 if (inboxActor === undefined) throw new Error('Need to reject on explicit inbox.')
8
9 const targetActor = await ActorModel.loadByUrl(activity.actor)
10
11 return processReject(inboxActor, targetActor)
12}
13
14// ---------------------------------------------------------------------------
15
16export {
17 processRejectActivity
18}
19
20// ---------------------------------------------------------------------------
21
22async function processReject (actor: ActorModel, targetActor: ActorModel) {
23 return sequelizeTypescript.transaction(async t => {
24 const actorFollow = await ActorFollowModel.loadByActorAndTarget(actor.id, targetActor.id, t)
25
26 if (!actorFollow) throw new Error(`'Unknown actor follow ${actor.id} -> ${targetActor.id}.`)
27
28 await actorFollow.destroy({ transaction: t })
29
30 return undefined
31 })
32}
diff --git a/server/lib/activitypub/process/process.ts b/server/lib/activitypub/process/process.ts
index 62d310f21..810c28e26 100644
--- a/server/lib/activitypub/process/process.ts
+++ b/server/lib/activitypub/process/process.ts
@@ -7,6 +7,7 @@ import { processCreateActivity } from './process-create'
7import { processDeleteActivity } from './process-delete' 7import { processDeleteActivity } from './process-delete'
8import { processFollowActivity } from './process-follow' 8import { processFollowActivity } from './process-follow'
9import { processLikeActivity } from './process-like' 9import { processLikeActivity } from './process-like'
10import { processRejectActivity } from './process-reject'
10import { processUndoActivity } from './process-undo' 11import { processUndoActivity } from './process-undo'
11import { processUpdateActivity } from './process-update' 12import { processUpdateActivity } from './process-update'
12 13
@@ -16,6 +17,7 @@ const processActivity: { [ P in ActivityType ]: (activity: Activity, inboxActor?
16 Delete: processDeleteActivity, 17 Delete: processDeleteActivity,
17 Follow: processFollowActivity, 18 Follow: processFollowActivity,
18 Accept: processAcceptActivity, 19 Accept: processAcceptActivity,
20 Reject: processRejectActivity,
19 Announce: processAnnounceActivity, 21 Announce: processAnnounceActivity,
20 Undo: processUndoActivity, 22 Undo: processUndoActivity,
21 Like: processLikeActivity 23 Like: processLikeActivity