1
0
Fork 0
peertube/server/lib/activitypub/process/process-reject.ts

33 lines
1.2 KiB
TypeScript
Raw Normal View History

2018-01-11 11:37:49 -05:00
import { ActivityReject } from '../../../../shared/models/activitypub/activity'
2020-05-07 08:58:24 -04:00
import { sequelizeTypescript } from '../../../initializers/database'
2021-05-11 05:15:29 -04:00
import { ActorFollowModel } from '../../../models/actor/actor-follow'
2020-06-18 04:45:25 -04:00
import { APProcessorOptions } from '../../../types/activitypub-processor.model'
import { MActor } from '../../../types/models'
2018-01-11 11:37:49 -05:00
2019-08-02 04:53:36 -04:00
async function processRejectActivity (options: APProcessorOptions<ActivityReject>) {
const { byActor: targetActor, inboxActor } = options
2018-01-11 11:37:49 -05:00
if (inboxActor === undefined) throw new Error('Need to reject on explicit inbox.')
return processReject(inboxActor, targetActor)
}
// ---------------------------------------------------------------------------
export {
processRejectActivity
}
// ---------------------------------------------------------------------------
2019-08-15 05:53:26 -04:00
async function processReject (follower: MActor, targetActor: MActor) {
2018-01-11 11:37:49 -05:00
return sequelizeTypescript.transaction(async t => {
2018-09-19 09:47:55 -04:00
const actorFollow = await ActorFollowModel.loadByActorAndTarget(follower.id, targetActor.id, t)
2018-01-11 11:37:49 -05:00
2018-09-19 09:47:55 -04:00
if (!actorFollow) throw new Error(`'Unknown actor follow ${follower.id} -> ${targetActor.id}.`)
2018-01-11 11:37:49 -05:00
await actorFollow.destroy({ transaction: t })
return undefined
})
}