]>
Commit | Line | Data |
---|---|---|
1 | import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub' | |
2 | import { ActorModel } from '../../../models/activitypub/actor' | |
3 | import { getActorFollowActivityPubUrl, getActorFollowRejectActivityPubUrl } from '../url' | |
4 | import { unicastTo } from './utils' | |
5 | import { buildFollowActivity } from './send-follow' | |
6 | import { logger } from '../../../helpers/logger' | |
7 | import { SignatureActorModel } from '../../../typings/models' | |
8 | ||
9 | async function sendReject (follower: SignatureActorModel, following: ActorModel) { | |
10 | if (!follower.serverId) { // This should never happen | |
11 | logger.warn('Do not sending reject to local follower.') | |
12 | return | |
13 | } | |
14 | ||
15 | logger.info('Creating job to reject follower %s.', follower.url) | |
16 | ||
17 | const followUrl = getActorFollowActivityPubUrl(follower, following) | |
18 | const followData = buildFollowActivity(followUrl, follower, following) | |
19 | ||
20 | const url = getActorFollowRejectActivityPubUrl(follower, following) | |
21 | const data = buildRejectActivity(url, following, followData) | |
22 | ||
23 | return unicastTo(data, following, follower.inboxUrl) | |
24 | } | |
25 | ||
26 | // --------------------------------------------------------------------------- | |
27 | ||
28 | export { | |
29 | sendReject | |
30 | } | |
31 | ||
32 | // --------------------------------------------------------------------------- | |
33 | ||
34 | function buildRejectActivity (url: string, byActor: ActorModel, followActivityData: ActivityFollow): ActivityReject { | |
35 | return { | |
36 | type: 'Reject', | |
37 | id: url, | |
38 | actor: byActor.url, | |
39 | object: followActivityData | |
40 | } | |
41 | } |