mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +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
34
server/lib/activitypub/send/send-follow.ts
Normal file
34
server/lib/activitypub/send/send-follow.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { Transaction } from 'sequelize'
|
||||
import { ActivityFollow } from '../../../../shared/models/activitypub/activity'
|
||||
import { AccountInstance } from '../../../models'
|
||||
import { AccountFollowInstance } from '../../../models/account/account-follow-interface'
|
||||
import { unicastTo } from './misc'
|
||||
import { getAccountFollowActivityPubUrl } from '../../../helpers/activitypub'
|
||||
|
||||
async function sendFollow (accountFollow: AccountFollowInstance, t: Transaction) {
|
||||
const me = accountFollow.AccountFollower
|
||||
const following = accountFollow.AccountFollowing
|
||||
|
||||
const url = getAccountFollowActivityPubUrl(accountFollow)
|
||||
const data = await followActivityData(url, me, following)
|
||||
|
||||
return unicastTo(data, me, following.inboxUrl, t)
|
||||
}
|
||||
|
||||
async function followActivityData (url: string, byAccount: AccountInstance, targetAccount: AccountInstance) {
|
||||
const activity: ActivityFollow = {
|
||||
type: 'Follow',
|
||||
id: url,
|
||||
actor: byAccount.url,
|
||||
object: targetAccount.url
|
||||
}
|
||||
|
||||
return activity
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
sendFollow,
|
||||
followActivityData
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue