]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/activitypub/send/send-accept.ts
Add more info logging
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-accept.ts
CommitLineData
e12a0092 1import { ActivityAccept, ActivityFollow } from '../../../../shared/models/activitypub'
50d6de9c
C
2import { ActorModel } from '../../../models/activitypub/actor'
3import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
e12a0092 4import { getActorFollowAcceptActivityPubUrl, getActorFollowActivityPubUrl } from '../url'
e251f170 5import { unicastTo } from './utils'
e12a0092 6import { followActivityData } from './send-follow'
8e0fd45e 7import { logger } from '../../../helpers/logger'
54141398 8
94a5ff8a 9async function sendAccept (actorFollow: ActorFollowModel) {
50d6de9c
C
10 const follower = actorFollow.ActorFollower
11 const me = actorFollow.ActorFollowing
54141398 12
8e0fd45e
C
13 logger.info('Creating job to accept follower %s.', follower.url)
14
e12a0092
C
15 const followUrl = getActorFollowActivityPubUrl(actorFollow)
16 const followData = followActivityData(followUrl, follower, me)
17
50d6de9c 18 const url = getActorFollowAcceptActivityPubUrl(actorFollow)
e12a0092 19 const data = acceptActivityData(url, me, followData)
54141398 20
94a5ff8a 21 return unicastTo(data, me, follower.inboxUrl)
54141398
C
22}
23
24// ---------------------------------------------------------------------------
25
26export {
27 sendAccept
28}
29
30// ---------------------------------------------------------------------------
31
e12a0092 32function acceptActivityData (url: string, byActor: ActorModel, followActivityData: ActivityFollow): ActivityAccept {
50d6de9c 33 return {
54141398
C
34 type: 'Accept',
35 id: url,
e12a0092
C
36 actor: byActor.url,
37 object: followActivityData
54141398 38 }
54141398 39}