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

35 lines
1.0 KiB
TypeScript
Raw Normal View History

2017-11-20 02:43:39 -06:00
import { Transaction } from 'sequelize'
2017-12-12 10:53:50 -06:00
import { ActivityAccept } from '../../../../shared/models/activitypub'
import { AccountModel } from '../../../models/account/account'
import { AccountFollowModel } from '../../../models/account/account-follow'
import { getAccountFollowAcceptActivityPubUrl } from '../url'
2017-12-12 10:53:50 -06:00
import { unicastTo } from './misc'
2017-11-20 02:43:39 -06:00
2017-12-12 10:53:50 -06:00
async function sendAccept (accountFollow: AccountFollowModel, t: Transaction) {
2017-11-20 02:43:39 -06:00
const follower = accountFollow.AccountFollower
const me = accountFollow.AccountFollowing
const url = getAccountFollowAcceptActivityPubUrl(accountFollow)
const data = acceptActivityData(url, me)
2017-11-20 02:43:39 -06:00
return unicastTo(data, me, follower.inboxUrl, t)
}
// ---------------------------------------------------------------------------
export {
sendAccept
}
// ---------------------------------------------------------------------------
2017-12-12 10:53:50 -06:00
function acceptActivityData (url: string, byAccount: AccountModel) {
2017-11-20 02:43:39 -06:00
const activity: ActivityAccept = {
type: 'Accept',
id: url,
actor: byAccount.url
}
return activity
}