]>
Commit | Line | Data |
---|---|---|
0e9c48c2 C |
1 | import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub' |
2 | import { ActorModel } from '../../../models/activitypub/actor' | |
5b9c965d | 3 | import { getActorFollowActivityPubUrl, getActorFollowRejectActivityPubUrl } from '../url' |
0e9c48c2 C |
4 | import { unicastTo } from './utils' |
5 | import { buildFollowActivity } from './send-follow' | |
6 | import { logger } from '../../../helpers/logger' | |
5224c394 | 7 | import { SignatureActorModel } from '../../../typings/models' |
0e9c48c2 | 8 | |
5224c394 | 9 | async function sendReject (follower: SignatureActorModel, following: ActorModel) { |
0e9c48c2 C |
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 | ||
5b9c965d C |
17 | const followUrl = getActorFollowActivityPubUrl(follower, following) |
18 | const followData = buildFollowActivity(followUrl, follower, following) | |
0e9c48c2 | 19 | |
5b9c965d C |
20 | const url = getActorFollowRejectActivityPubUrl(follower, following) |
21 | const data = buildRejectActivity(url, following, followData) | |
0e9c48c2 | 22 | |
5b9c965d | 23 | return unicastTo(data, following, follower.inboxUrl) |
0e9c48c2 C |
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 | } |