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