PeerTube/server/lib/activitypub/send/send-accept.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2017-11-20 09:43:39 +01:00
import { Transaction } from 'sequelize'
import { ActivityAccept } from '../../../../shared/models/activitypub/activity'
import { AccountInstance } from '../../../models'
import { AccountFollowInstance } from '../../../models/account/account-follow-interface'
import { unicastTo } from './misc'
import { getAccountFollowAcceptActivityPubUrl } from '../url'
2017-11-20 09:43:39 +01:00
async function sendAccept (accountFollow: AccountFollowInstance, t: Transaction) {
const follower = accountFollow.AccountFollower
const me = accountFollow.AccountFollowing
const url = getAccountFollowAcceptActivityPubUrl(accountFollow)
const data = await acceptActivityData(url, me)
return unicastTo(data, me, follower.inboxUrl, t)
}
// ---------------------------------------------------------------------------
export {
sendAccept
}
// ---------------------------------------------------------------------------
async function acceptActivityData (url: string, byAccount: AccountInstance) {
const activity: ActivityAccept = {
type: 'Accept',
id: url,
actor: byAccount.url
}
return activity
}