PeerTube/server/lib/activitypub/send/send-reject.ts

40 lines
1.3 KiB
TypeScript
Raw Normal View History

import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub'
import { logger } from '../../../helpers/logger'
2020-06-18 03:45:25 -05:00
import { MActor } from '../../../types/models'
2020-11-20 04:21:08 -06:00
import { getLocalActorFollowRejectActivityPubUrl } from '../url'
import { buildFollowActivity } from './send-follow'
import { unicastTo } from './utils'
2020-11-20 04:21:08 -06:00
function sendReject (followUrl: string, follower: MActor, following: MActor) {
if (!follower.serverId) { // This should never happen
logger.warn('Do not sending reject to local follower.')
return
}
logger.info('Creating job to reject follower %s.', follower.url)
2019-04-08 07:04:57 -05:00
const followData = buildFollowActivity(followUrl, follower, following)
2020-11-20 04:21:08 -06:00
const url = getLocalActorFollowRejectActivityPubUrl(follower, following)
2019-04-08 07:04:57 -05:00
const data = buildRejectActivity(url, following, followData)
2019-04-08 07:04:57 -05:00
return unicastTo(data, following, follower.inboxUrl)
}
// ---------------------------------------------------------------------------
export {
sendReject
}
// ---------------------------------------------------------------------------
2019-08-15 04:53:26 -05:00
function buildRejectActivity (url: string, byActor: MActor, followActivityData: ActivityFollow): ActivityReject {
return {
type: 'Reject',
id: url,
actor: byActor.url,
object: followActivityData
}
}