aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/send/index.ts2
-rw-r--r--server/lib/activitypub/send/send-reject.ts44
2 files changed, 46 insertions, 0 deletions
diff --git a/server/lib/activitypub/send/index.ts b/server/lib/activitypub/send/index.ts
index 79ba6c7fe..028936810 100644
--- a/server/lib/activitypub/send/index.ts
+++ b/server/lib/activitypub/send/index.ts
@@ -1,8 +1,10 @@
1export * from './send-accept' 1export * from './send-accept'
2export * from './send-accept'
2export * from './send-announce' 3export * from './send-announce'
3export * from './send-create' 4export * from './send-create'
4export * from './send-delete' 5export * from './send-delete'
5export * from './send-follow' 6export * from './send-follow'
6export * from './send-like' 7export * from './send-like'
8export * from './send-reject'
7export * from './send-undo' 9export * from './send-undo'
8export * from './send-update' 10export * from './send-update'
diff --git a/server/lib/activitypub/send/send-reject.ts b/server/lib/activitypub/send/send-reject.ts
new file mode 100644
index 000000000..db8c2d86d
--- /dev/null
+++ b/server/lib/activitypub/send/send-reject.ts
@@ -0,0 +1,44 @@
1import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub'
2import { ActorModel } from '../../../models/activitypub/actor'
3import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
4import { getActorFollowAcceptActivityPubUrl, getActorFollowActivityPubUrl } from '../url'
5import { unicastTo } from './utils'
6import { buildFollowActivity } from './send-follow'
7import { logger } from '../../../helpers/logger'
8
9async function sendReject (actorFollow: ActorFollowModel) {
10 const follower = actorFollow.ActorFollower
11 const me = actorFollow.ActorFollowing
12
13 if (!follower.serverId) { // This should never happen
14 logger.warn('Do not sending reject to local follower.')
15 return
16 }
17
18 logger.info('Creating job to reject follower %s.', follower.url)
19
20 const followUrl = getActorFollowActivityPubUrl(actorFollow)
21 const followData = buildFollowActivity(followUrl, follower, me)
22
23 const url = getActorFollowAcceptActivityPubUrl(actorFollow)
24 const data = buildRejectActivity(url, me, followData)
25
26 return unicastTo(data, me, follower.inboxUrl)
27}
28
29// ---------------------------------------------------------------------------
30
31export {
32 sendReject
33}
34
35// ---------------------------------------------------------------------------
36
37function buildRejectActivity (url: string, byActor: ActorModel, followActivityData: ActivityFollow): ActivityReject {
38 return {
39 type: 'Reject',
40 id: url,
41 actor: byActor.url,
42 object: followActivityData
43 }
44}