]>
Commit | Line | Data |
---|---|---|
54141398 C |
1 | import { ActivityAccept } from '../../../../shared/models/activitypub/activity' |
2 | import { database as db } from '../../../initializers' | |
3 | import { AccountInstance } from '../../../models/account/account-interface' | |
c46edbc2 | 4 | import { addFetchOutboxJob } from '../fetch' |
7a7724e6 C |
5 | |
6 | async function processAcceptActivity (activity: ActivityAccept, inboxAccount?: AccountInstance) { | |
7 | if (inboxAccount === undefined) throw new Error('Need to accept on explicit inbox.') | |
8 | ||
9 | const targetAccount = await db.Account.loadByUrl(activity.actor) | |
10 | ||
ce548a10 | 11 | return processAccept(inboxAccount, targetAccount) |
7a7724e6 C |
12 | } |
13 | ||
14 | // --------------------------------------------------------------------------- | |
15 | ||
16 | export { | |
17 | processAcceptActivity | |
18 | } | |
19 | ||
20 | // --------------------------------------------------------------------------- | |
21 | ||
ce548a10 | 22 | async function processAccept (account: AccountInstance, targetAccount: AccountInstance) { |
7a7724e6 C |
23 | const follow = await db.AccountFollow.loadByAccountAndTarget(account.id, targetAccount.id) |
24 | if (!follow) throw new Error('Cannot find associated follow.') | |
25 | ||
26 | follow.set('state', 'accepted') | |
ce548a10 | 27 | await follow.save() |
c46edbc2 | 28 | await addFetchOutboxJob(targetAccount, undefined) |
7a7724e6 | 29 | } |