2019-04-08 11:52:29 +02:00
|
|
|
import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub'
|
2019-04-08 14:04:57 +02:00
|
|
|
import { getActorFollowActivityPubUrl, getActorFollowRejectActivityPubUrl } from '../url'
|
2019-04-08 11:52:29 +02:00
|
|
|
import { unicastTo } from './utils'
|
|
|
|
import { buildFollowActivity } from './send-follow'
|
|
|
|
import { logger } from '../../../helpers/logger'
|
2019-08-15 11:53:26 +02:00
|
|
|
import { MActor } from '../../../typings/models'
|
2019-04-08 11:52:29 +02:00
|
|
|
|
2019-08-15 11:53:26 +02:00
|
|
|
async function sendReject (follower: MActor, following: MActor) {
|
2019-04-08 11:52:29 +02:00
|
|
|
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 14:04:57 +02:00
|
|
|
const followUrl = getActorFollowActivityPubUrl(follower, following)
|
|
|
|
const followData = buildFollowActivity(followUrl, follower, following)
|
2019-04-08 11:52:29 +02:00
|
|
|
|
2019-04-08 14:04:57 +02:00
|
|
|
const url = getActorFollowRejectActivityPubUrl(follower, following)
|
|
|
|
const data = buildRejectActivity(url, following, followData)
|
2019-04-08 11:52:29 +02:00
|
|
|
|
2019-04-08 14:04:57 +02:00
|
|
|
return unicastTo(data, following, follower.inboxUrl)
|
2019-04-08 11:52:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
sendReject
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2019-08-15 11:53:26 +02:00
|
|
|
function buildRejectActivity (url: string, byActor: MActor, followActivityData: ActivityFollow): ActivityReject {
|
2019-04-08 11:52:29 +02:00
|
|
|
return {
|
|
|
|
type: 'Reject',
|
|
|
|
id: url,
|
|
|
|
actor: byActor.url,
|
|
|
|
object: followActivityData
|
|
|
|
}
|
|
|
|
}
|