mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
Refractor activity pub lib/helpers
This commit is contained in:
parent
eb8b27c93e
commit
5414139835
47 changed files with 844 additions and 498 deletions
27
server/lib/activitypub/process/process-accept.ts
Normal file
27
server/lib/activitypub/process/process-accept.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { ActivityAccept } from '../../../../shared/models/activitypub/activity'
|
||||
import { database as db } from '../../../initializers'
|
||||
import { AccountInstance } from '../../../models/account/account-interface'
|
||||
|
||||
async function processAcceptActivity (activity: ActivityAccept, inboxAccount?: AccountInstance) {
|
||||
if (inboxAccount === undefined) throw new Error('Need to accept on explicit inbox.')
|
||||
|
||||
const targetAccount = await db.Account.loadByUrl(activity.actor)
|
||||
|
||||
return processAccept(inboxAccount, targetAccount)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
processAcceptActivity
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function processAccept (account: AccountInstance, targetAccount: AccountInstance) {
|
||||
const follow = await db.AccountFollow.loadByAccountAndTarget(account.id, targetAccount.id)
|
||||
if (!follow) throw new Error('Cannot find associated follow.')
|
||||
|
||||
follow.set('state', 'accepted')
|
||||
await follow.save()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue