]>
Commit | Line | Data |
---|---|---|
54141398 | 1 | import { Transaction } from 'sequelize' |
3fd3ab2d | 2 | import { ActivityAccept } from '../../../../shared/models/activitypub' |
50d6de9c C |
3 | import { ActorModel } from '../../../models/activitypub/actor' |
4 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | |
5 | import { getActorFollowAcceptActivityPubUrl } from '../url' | |
3fd3ab2d | 6 | import { unicastTo } from './misc' |
54141398 | 7 | |
50d6de9c C |
8 | async function sendAccept (actorFollow: ActorFollowModel, t: Transaction) { |
9 | const follower = actorFollow.ActorFollower | |
10 | const me = actorFollow.ActorFollowing | |
54141398 | 11 | |
50d6de9c | 12 | const url = getActorFollowAcceptActivityPubUrl(actorFollow) |
25ed141c | 13 | const data = acceptActivityData(url, me) |
54141398 C |
14 | |
15 | return unicastTo(data, me, follower.inboxUrl, t) | |
16 | } | |
17 | ||
18 | // --------------------------------------------------------------------------- | |
19 | ||
20 | export { | |
21 | sendAccept | |
22 | } | |
23 | ||
24 | // --------------------------------------------------------------------------- | |
25 | ||
50d6de9c C |
26 | function acceptActivityData (url: string, byActor: ActorModel): ActivityAccept { |
27 | return { | |
54141398 C |
28 | type: 'Accept', |
29 | id: url, | |
50d6de9c | 30 | actor: byActor.url |
54141398 | 31 | } |
54141398 | 32 | } |