2017-12-12 11:53:50 -05:00
|
|
|
import { ActivityFollow } from '../../../../shared/models/activitypub'
|
2017-12-14 11:38:41 -05:00
|
|
|
import { ActorModel } from '../../../models/activitypub/actor'
|
|
|
|
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
|
|
|
|
import { getActorFollowActivityPubUrl } from '../url'
|
2017-11-20 03:43:39 -05:00
|
|
|
import { unicastTo } from './misc'
|
|
|
|
|
2018-01-25 09:05:18 -05:00
|
|
|
function sendFollow (actorFollow: ActorFollowModel) {
|
2017-12-14 11:38:41 -05:00
|
|
|
const me = actorFollow.ActorFollower
|
|
|
|
const following = actorFollow.ActorFollowing
|
2017-11-20 03:43:39 -05:00
|
|
|
|
2017-12-14 11:38:41 -05:00
|
|
|
const url = getActorFollowActivityPubUrl(actorFollow)
|
2017-11-30 05:31:15 -05:00
|
|
|
const data = followActivityData(url, me, following)
|
2017-11-20 03:43:39 -05:00
|
|
|
|
2018-01-25 09:05:18 -05:00
|
|
|
return unicastTo(data, me, following.inboxUrl)
|
2017-11-20 03:43:39 -05:00
|
|
|
}
|
|
|
|
|
2017-12-14 11:38:41 -05:00
|
|
|
function followActivityData (url: string, byActor: ActorModel, targetActor: ActorModel): ActivityFollow {
|
2017-12-12 11:53:50 -05:00
|
|
|
return {
|
2017-11-20 03:43:39 -05:00
|
|
|
type: 'Follow',
|
|
|
|
id: url,
|
2017-12-14 11:38:41 -05:00
|
|
|
actor: byActor.url,
|
|
|
|
object: targetActor.url
|
2017-11-20 03:43:39 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
sendFollow,
|
|
|
|
followActivityData
|
|
|
|
}
|