diff options
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/activitypub/activity.ts | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts index 8c2920328..4aace4c8e 100644 --- a/server/middlewares/validators/activitypub/activity.ts +++ b/server/middlewares/validators/activitypub/activity.ts | |||
@@ -6,24 +6,23 @@ import { getServerActor } from '../../../helpers/utils' | |||
6 | import { ActorModel } from '../../../models/activitypub/actor' | 6 | import { ActorModel } from '../../../models/activitypub/actor' |
7 | import { areValidationErrors } from '../utils' | 7 | import { areValidationErrors } from '../utils' |
8 | 8 | ||
9 | const activityPubValidator = [ | 9 | async function activityPubValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
10 | body('').custom((value, { req }) => isRootActivityValid(req.body)), | 10 | logger.debug('Checking activity pub parameters') |
11 | 11 | ||
12 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 12 | if (!isRootActivityValid(req.body)) { |
13 | logger.debug('Checking activity pub parameters') | 13 | logger.warn('Incorrect activity parameters.', { activity: req.body }) |
14 | 14 | return res.status(400).json({ error: 'Incorrect activity.' }) | |
15 | if (areValidationErrors(req, res)) return | 15 | } |
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.status(409).end() | ||
22 | } | ||
23 | 16 | ||
24 | return next() | 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.status(409).end() | ||
25 | } | 22 | } |
26 | ] | 23 | |
24 | return next() | ||
25 | } | ||
27 | 26 | ||
28 | // --------------------------------------------------------------------------- | 27 | // --------------------------------------------------------------------------- |
29 | 28 | ||