diff options
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/activitypub/activity.ts | 11 |
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' | |||
2 | import { body } from 'express-validator/check' | 2 | import { body } from 'express-validator/check' |
3 | import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity' | 3 | import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity' |
4 | import { logger } from '../../../helpers/logger' | 4 | import { logger } from '../../../helpers/logger' |
5 | import { getServerActor } from '../../../helpers/utils' | ||
6 | import { ActorModel } from '../../../models/activitypub/actor' | ||
5 | import { areValidationErrors } from '../utils' | 7 | import { areValidationErrors } from '../utils' |
6 | 8 | ||
7 | const activityPubValidator = [ | 9 | const 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 | ] |