]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/activitypub/send/send-reject.ts
Remove octet stream fallback for video extension
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-reject.ts
1 import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub'
2 import { getActorFollowActivityPubUrl, getActorFollowRejectActivityPubUrl } from '../url'
3 import { unicastTo } from './utils'
4 import { buildFollowActivity } from './send-follow'
5 import { logger } from '../../../helpers/logger'
6 import { MActor } from '../../../typings/models'
7
8 async function sendReject (follower: MActor, following: MActor) {
9 if (!follower.serverId) { // This should never happen
10 logger.warn('Do not sending reject to local follower.')
11 return
12 }
13
14 logger.info('Creating job to reject follower %s.', follower.url)
15
16 const followUrl = getActorFollowActivityPubUrl(follower, following)
17 const followData = buildFollowActivity(followUrl, follower, following)
18
19 const url = getActorFollowRejectActivityPubUrl(follower, following)
20 const data = buildRejectActivity(url, following, followData)
21
22 return unicastTo(data, following, follower.inboxUrl)
23 }
24
25 // ---------------------------------------------------------------------------
26
27 export {
28 sendReject
29 }
30
31 // ---------------------------------------------------------------------------
32
33 function buildRejectActivity (url: string, byActor: MActor, followActivityData: ActivityFollow): ActivityReject {
34 return {
35 type: 'Reject',
36 id: url,
37 actor: byActor.url,
38 object: followActivityData
39 }
40 }