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'
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.')
14 logger.info('Creating job to reject follower %s.', follower.url)
16 const followUrl = getActorFollowActivityPubUrl(follower, following)
17 const followData = buildFollowActivity(followUrl, follower, following)
19 const url = getActorFollowRejectActivityPubUrl(follower, following)
20 const data = buildRejectActivity(url, following, followData)
22 return unicastTo(data, following, follower.inboxUrl)
25 // ---------------------------------------------------------------------------
31 // ---------------------------------------------------------------------------
33 function buildRejectActivity (url: string, byActor: MActor, followActivityData: ActivityFollow): ActivityReject {
38 object: followActivityData