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

33 lines
1007 B
TypeScript
Raw Normal View History

2017-11-20 09:43:39 +01:00
import { Transaction } from 'sequelize'
2017-12-12 17:53:50 +01:00
import { ActivityAccept } from '../../../../shared/models/activitypub'
2017-12-14 17:38:41 +01:00
import { ActorModel } from '../../../models/activitypub/actor'
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { getActorFollowAcceptActivityPubUrl } from '../url'
2017-12-12 17:53:50 +01:00
import { unicastTo } from './misc'
2017-11-20 09:43:39 +01:00
2017-12-14 17:38:41 +01:00
async function sendAccept (actorFollow: ActorFollowModel, t: Transaction) {
const follower = actorFollow.ActorFollower
const me = actorFollow.ActorFollowing
2017-11-20 09:43:39 +01:00
2017-12-14 17:38:41 +01:00
const url = getActorFollowAcceptActivityPubUrl(actorFollow)
const data = acceptActivityData(url, me)
2017-11-20 09:43:39 +01:00
return unicastTo(data, me, follower.inboxUrl, t)
}
// ---------------------------------------------------------------------------
export {
sendAccept
}
// ---------------------------------------------------------------------------
2017-12-14 17:38:41 +01:00
function acceptActivityData (url: string, byActor: ActorModel): ActivityAccept {
return {
2017-11-20 09:43:39 +01:00
type: 'Accept',
id: url,
2017-12-14 17:38:41 +01:00
actor: byActor.url
2017-11-20 09:43:39 +01:00
}
}