aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/activitypub/activity.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts
index 208e23f86..15e8bb079 100644
--- a/server/middlewares/validators/activitypub/activity.ts
+++ b/server/middlewares/validators/activitypub/activity.ts
@@ -2,16 +2,25 @@ import * as express from 'express'
2import { body } from 'express-validator/check' 2import { body } from 'express-validator/check'
3import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity' 3import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { getServerActor } from '../../../helpers/utils'
6import { ActorModel } from '../../../models/activitypub/actor'
5import { areValidationErrors } from '../utils' 7import { areValidationErrors } from '../utils'
6 8
7const activityPubValidator = [ 9const activityPubValidator = [
8 body('').custom((value, { req }) => isRootActivityValid(req.body)), 10 body('').custom((value, { req }) => isRootActivityValid(req.body)),
9 11
10 (req: express.Request, res: express.Response, next: express.NextFunction) => { 12 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
11 logger.debug('Checking activity pub parameters') 13 logger.debug('Checking activity pub parameters')
12 14
13 if (areValidationErrors(req, res)) return 15 if (areValidationErrors(req, res)) return
14 16
17 const serverActor = await getServerActor()
18 const remoteActor = res.locals.signature.actor as ActorModel
19 if (serverActor.id === remoteActor.id) {
20 logger.error('Receiving request in INBOX by ourselves!', req.body)
21 return res.sendStatus(409)
22 }
23
15 return next() 24 return next()
16 } 25 }
17] 26]