diff options
Diffstat (limited to 'server/middlewares/activitypub.ts')
-rw-r--r-- | server/middlewares/activitypub.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts index 37b7c42ec..9113e02a7 100644 --- a/server/middlewares/activitypub.ts +++ b/server/middlewares/activitypub.ts | |||
@@ -9,11 +9,13 @@ import { ActorModel } from '../models/activitypub/actor' | |||
9 | async function checkSignature (req: Request, res: Response, next: NextFunction) { | 9 | async function checkSignature (req: Request, res: Response, next: NextFunction) { |
10 | const signatureObject: ActivityPubSignature = req.body.signature | 10 | const signatureObject: ActivityPubSignature = req.body.signature |
11 | 11 | ||
12 | logger.debug('Checking signature of actor %s...', signatureObject.creator) | 12 | const [ creator ] = signatureObject.creator.split('#') |
13 | |||
14 | logger.debug('Checking signature of actor %s...', creator) | ||
13 | 15 | ||
14 | let actor: ActorModel | 16 | let actor: ActorModel |
15 | try { | 17 | try { |
16 | actor = await getOrCreateActorAndServerAndModel(signatureObject.creator) | 18 | actor = await getOrCreateActorAndServerAndModel(creator) |
17 | } catch (err) { | 19 | } catch (err) { |
18 | logger.error('Cannot create remote actor and check signature.', err) | 20 | logger.error('Cannot create remote actor and check signature.', err) |
19 | return res.sendStatus(403) | 21 | return res.sendStatus(403) |
@@ -32,6 +34,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction) | |||
32 | function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) { | 34 | function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) { |
33 | return (req: Request, res: Response, next: NextFunction) => { | 35 | return (req: Request, res: Response, next: NextFunction) => { |
34 | const accepted = req.accepts(ACCEPT_HEADERS) | 36 | const accepted = req.accepts(ACCEPT_HEADERS) |
37 | console.log(accepted) | ||
35 | if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) { | 38 | if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) { |
36 | return next() | 39 | return next() |
37 | } | 40 | } |