]>
Commit | Line | Data |
---|---|---|
e12a0092 | 1 | import { ActivityAccept, ActivityFollow } from '../../../../shared/models/activitypub' |
50d6de9c C |
2 | import { ActorModel } from '../../../models/activitypub/actor' |
3 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | |
e12a0092 | 4 | import { getActorFollowAcceptActivityPubUrl, getActorFollowActivityPubUrl } from '../url' |
e251f170 | 5 | import { unicastTo } from './utils' |
e12a0092 | 6 | import { followActivityData } from './send-follow' |
8e0fd45e | 7 | import { logger } from '../../../helpers/logger' |
54141398 | 8 | |
94a5ff8a | 9 | async function sendAccept (actorFollow: ActorFollowModel) { |
50d6de9c C |
10 | const follower = actorFollow.ActorFollower |
11 | const me = actorFollow.ActorFollowing | |
54141398 | 12 | |
8e0fd45e C |
13 | logger.info('Creating job to accept follower %s.', follower.url) |
14 | ||
e12a0092 C |
15 | const followUrl = getActorFollowActivityPubUrl(actorFollow) |
16 | const followData = followActivityData(followUrl, follower, me) | |
17 | ||
50d6de9c | 18 | const url = getActorFollowAcceptActivityPubUrl(actorFollow) |
e12a0092 | 19 | const data = acceptActivityData(url, me, followData) |
54141398 | 20 | |
94a5ff8a | 21 | return unicastTo(data, me, follower.inboxUrl) |
54141398 C |
22 | } |
23 | ||
24 | // --------------------------------------------------------------------------- | |
25 | ||
26 | export { | |
27 | sendAccept | |
28 | } | |
29 | ||
30 | // --------------------------------------------------------------------------- | |
31 | ||
e12a0092 | 32 | function acceptActivityData (url: string, byActor: ActorModel, followActivityData: ActivityFollow): ActivityAccept { |
50d6de9c | 33 | return { |
54141398 C |
34 | type: 'Accept', |
35 | id: url, | |
e12a0092 C |
36 | actor: byActor.url, |
37 | object: followActivityData | |
54141398 | 38 | } |
54141398 | 39 | } |