]>
Commit | Line | Data |
---|---|---|
3fd3ab2d | 1 | import { ActivityAccept } from '../../../../shared/models/activitypub' |
50d6de9c C |
2 | import { ActorModel } from '../../../models/activitypub/actor' |
3 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | |
16f29007 | 4 | import { addFetchOutboxJob } from '../actor' |
7a7724e6 | 5 | |
e587e0ec | 6 | async function processAcceptActivity (activity: ActivityAccept, targetActor: ActorModel, inboxActor?: ActorModel) { |
50d6de9c | 7 | if (inboxActor === undefined) throw new Error('Need to accept on explicit inbox.') |
7a7724e6 | 8 | |
50d6de9c | 9 | return processAccept(inboxActor, targetActor) |
7a7724e6 C |
10 | } |
11 | ||
12 | // --------------------------------------------------------------------------- | |
13 | ||
14 | export { | |
15 | processAcceptActivity | |
16 | } | |
17 | ||
18 | // --------------------------------------------------------------------------- | |
19 | ||
50d6de9c C |
20 | async function processAccept (actor: ActorModel, targetActor: ActorModel) { |
21 | const follow = await ActorFollowModel.loadByActorAndTarget(actor.id, targetActor.id) | |
7a7724e6 C |
22 | if (!follow) throw new Error('Cannot find associated follow.') |
23 | ||
7bc29171 C |
24 | if (follow.state !== 'accepted') { |
25 | follow.set('state', 'accepted') | |
26 | await follow.save() | |
f7cc67b4 | 27 | |
94a5ff8a | 28 | await addFetchOutboxJob(targetActor) |
7bc29171 | 29 | } |
7a7724e6 | 30 | } |