]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/activitypub.ts
Avoid making retried requests to dead followers
[github/Chocobozzz/PeerTube.git] / server / middlewares / activitypub.ts
index 37b7c42ec3c49db64e4763202728cd5a27e8001d..1488b42ab1164bd701db841182da7d92c7eb0613 100644 (file)
@@ -1,7 +1,8 @@
 import { eachSeries } from 'async'
 import { NextFunction, Request, RequestHandler, Response } from 'express'
 import { ActivityPubSignature } from '../../shared'
-import { isSignatureVerified, logger } from '../helpers'
+import { logger } from '../helpers/logger'
+import { isSignatureVerified } from '../helpers/peertube-crypto'
 import { ACCEPT_HEADERS, ACTIVITY_PUB } from '../initializers'
 import { getOrCreateActorAndServerAndModel } from '../lib/activitypub'
 import { ActorModel } from '../models/activitypub/actor'
@@ -9,11 +10,13 @@ import { ActorModel } from '../models/activitypub/actor'
 async function checkSignature (req: Request, res: Response, next: NextFunction) {
   const signatureObject: ActivityPubSignature = req.body.signature
 
-  logger.debug('Checking signature of actor %s...', signatureObject.creator)
+  const [ creator ] = signatureObject.creator.split('#')
+
+  logger.debug('Checking signature of actor %s...', creator)
 
   let actor: ActorModel
   try {
-    actor = await getOrCreateActorAndServerAndModel(signatureObject.creator)
+    actor = await getOrCreateActorAndServerAndModel(creator)
   } catch (err) {
     logger.error('Cannot create remote actor and check signature.', err)
     return res.sendStatus(403)