]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/lib/activitypub/send/send-follow.ts
Split files in activitypub server
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-follow.ts
... / ...
CommitLineData
1import { ActivityFollow } from '../../../../shared/models/activitypub'
2import { ActorModel } from '../../../models/activitypub/actor'
3import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
4import { getActorFollowActivityPubUrl } from '../url'
5import { unicastTo } from './utils'
6
7function sendFollow (actorFollow: ActorFollowModel) {
8 const me = actorFollow.ActorFollower
9 const following = actorFollow.ActorFollowing
10
11 const url = getActorFollowActivityPubUrl(actorFollow)
12 const data = followActivityData(url, me, following)
13
14 return unicastTo(data, me, following.inboxUrl)
15}
16
17function followActivityData (url: string, byActor: ActorModel, targetActor: ActorModel): ActivityFollow {
18 return {
19 type: 'Follow',
20 id: url,
21 actor: byActor.url,
22 object: targetActor.url
23 }
24}
25
26// ---------------------------------------------------------------------------
27
28export {
29 sendFollow,
30 followActivityData
31}