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'
|
2017-11-20 03:24:29 -06:00
|
|
|
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)
|
2017-11-30 04:31:15 -06:00
|
|
|
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
|
|
|
|
}
|