diff options
Diffstat (limited to 'server/lib/activitypub/send')
-rw-r--r-- | server/lib/activitypub/send/index.ts | 2 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-reject.ts | 44 |
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 @@ | |||
1 | export * from './send-accept' | 1 | export * from './send-accept' |
2 | export * from './send-accept' | ||
2 | export * from './send-announce' | 3 | export * from './send-announce' |
3 | export * from './send-create' | 4 | export * from './send-create' |
4 | export * from './send-delete' | 5 | export * from './send-delete' |
5 | export * from './send-follow' | 6 | export * from './send-follow' |
6 | export * from './send-like' | 7 | export * from './send-like' |
8 | export * from './send-reject' | ||
7 | export * from './send-undo' | 9 | export * from './send-undo' |
8 | export * from './send-update' | 10 | export * 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 @@ | |||
1 | import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub' | ||
2 | import { ActorModel } from '../../../models/activitypub/actor' | ||
3 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | ||
4 | import { getActorFollowAcceptActivityPubUrl, getActorFollowActivityPubUrl } from '../url' | ||
5 | import { unicastTo } from './utils' | ||
6 | import { buildFollowActivity } from './send-follow' | ||
7 | import { logger } from '../../../helpers/logger' | ||
8 | |||
9 | async 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 | |||
31 | export { | ||
32 | sendReject | ||
33 | } | ||
34 | |||
35 | // --------------------------------------------------------------------------- | ||
36 | |||
37 | function 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 | } | ||