2022-03-18 06:17:35 -04:00
|
|
|
import { ActivityFollow, ActivityReject } from '@shared/models'
|
2019-04-08 05:52:29 -04:00
|
|
|
import { logger } from '../../../helpers/logger'
|
2020-06-18 04:45:25 -04:00
|
|
|
import { MActor } from '../../../types/models'
|
2020-11-20 05:21:08 -05:00
|
|
|
import { getLocalActorFollowRejectActivityPubUrl } from '../url'
|
|
|
|
import { buildFollowActivity } from './send-follow'
|
2022-03-18 06:17:35 -04:00
|
|
|
import { unicastTo } from './shared/send-utils'
|
2019-04-08 05:52:29 -04:00
|
|
|
|
2020-11-20 05:21:08 -05:00
|
|
|
function sendReject (followUrl: string, follower: MActor, following: MActor) {
|
2019-04-08 05:52:29 -04: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 08:04:57 -04:00
|
|
|
const followData = buildFollowActivity(followUrl, follower, following)
|
2019-04-08 05:52:29 -04:00
|
|
|
|
2022-07-25 05:24:05 -04:00
|
|
|
const url = getLocalActorFollowRejectActivityPubUrl()
|
2019-04-08 08:04:57 -04:00
|
|
|
const data = buildRejectActivity(url, following, followData)
|
2019-04-08 05:52:29 -04:00
|
|
|
|
2022-03-23 11:14:33 -04:00
|
|
|
return unicastTo({ data, byActor: following, toActorUrl: follower.inboxUrl, contextType: 'Reject' })
|
2019-04-08 05:52:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
sendReject
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2019-08-15 05:53:26 -04:00
|
|
|
function buildRejectActivity (url: string, byActor: MActor, followActivityData: ActivityFollow): ActivityReject {
|
2019-04-08 05:52:29 -04:00
|
|
|
return {
|
|
|
|
type: 'Reject',
|
|
|
|
id: url,
|
|
|
|
actor: byActor.url,
|
|
|
|
object: followActivityData
|
|
|
|
}
|
|
|
|
}
|