]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/process/process-reject.ts
Merge branch 'release/2.3.0' into develop
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / process / process-reject.ts
index b0e6783166ac3c4b6d739e70b8ca3f6022e97be4..03b669fd99cc715bc5cdc8a694cf2cb9f23a3409 100644 (file)
@@ -1,9 +1,11 @@
 import { ActivityReject } from '../../../../shared/models/activitypub/activity'
-import { sequelizeTypescript } from '../../../initializers'
-import { ActorModel } from '../../../models/activitypub/actor'
+import { sequelizeTypescript } from '../../../initializers/database'
 import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
+import { APProcessorOptions } from '../../../types/activitypub-processor.model'
+import { MActor } from '../../../types/models'
 
-async function processRejectActivity (activity: ActivityReject, targetActor: ActorModel, inboxActor?: ActorModel) {
+async function processRejectActivity (options: APProcessorOptions<ActivityReject>) {
+  const { byActor: targetActor, inboxActor } = options
   if (inboxActor === undefined) throw new Error('Need to reject on explicit inbox.')
 
   return processReject(inboxActor, targetActor)
@@ -17,11 +19,11 @@ export {
 
 // ---------------------------------------------------------------------------
 
-async function processReject (actor: ActorModel, targetActor: ActorModel) {
+async function processReject (follower: MActor, targetActor: MActor) {
   return sequelizeTypescript.transaction(async t => {
-    const actorFollow = await ActorFollowModel.loadByActorAndTarget(actor.id, targetActor.id, t)
+    const actorFollow = await ActorFollowModel.loadByActorAndTarget(follower.id, targetActor.id, t)
 
-    if (!actorFollow) throw new Error(`'Unknown actor follow ${actor.id} -> ${targetActor.id}.`)
+    if (!actorFollow) throw new Error(`'Unknown actor follow ${follower.id} -> ${targetActor.id}.`)
 
     await actorFollow.destroy({ transaction: t })