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