]>
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' |
54141398 | 7 | |
94a5ff8a | 8 | async function sendAccept (actorFollow: ActorFollowModel) { |
50d6de9c C |
9 | const follower = actorFollow.ActorFollower |
10 | const me = actorFollow.ActorFollowing | |
54141398 | 11 | |
e12a0092 C |
12 | const followUrl = getActorFollowActivityPubUrl(actorFollow) |
13 | const followData = followActivityData(followUrl, follower, me) | |
14 | ||
50d6de9c | 15 | const url = getActorFollowAcceptActivityPubUrl(actorFollow) |
e12a0092 | 16 | const data = acceptActivityData(url, me, followData) |
54141398 | 17 | |
94a5ff8a | 18 | return unicastTo(data, me, follower.inboxUrl) |
54141398 C |
19 | } |
20 | ||
21 | // --------------------------------------------------------------------------- | |
22 | ||
23 | export { | |
24 | sendAccept | |
25 | } | |
26 | ||
27 | // --------------------------------------------------------------------------- | |
28 | ||
e12a0092 | 29 | function acceptActivityData (url: string, byActor: ActorModel, followActivityData: ActivityFollow): ActivityAccept { |
50d6de9c | 30 | return { |
54141398 C |
31 | type: 'Accept', |
32 | id: url, | |
e12a0092 C |
33 | actor: byActor.url, |
34 | object: followActivityData | |
54141398 | 35 | } |
54141398 | 36 | } |