1
0
Fork 0
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:
Chocobozzz 2017-11-20 09:43:39 +01:00
parent eb8b27c93e
commit 5414139835
No known key found for this signature in database
GPG key ID: 583A612D890159BE
47 changed files with 844 additions and 498 deletions

View 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
}