aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-04-06 11:54:24 +0200
committerChocobozzz <me@florianbigard.com>2018-04-06 14:39:19 +0200
commitee28cdf1c488ac6ad6f3d06804b9c5e63eea1965 (patch)
tree23c614a34d09b565b3c428a77df72541d4653418 /server/middlewares
parent228e84aa7e604c010ecc39bd54b62fefcca3b94e (diff)
downloadPeerTube-ee28cdf1c488ac6ad6f3d06804b9c5e63eea1965.tar.gz
PeerTube-ee28cdf1c488ac6ad6f3d06804b9c5e63eea1965.tar.zst
PeerTube-ee28cdf1c488ac6ad6f3d06804b9c5e63eea1965.zip
Upgrade server dependencies
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/activitypub/activity.ts29
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'
6import { ActorModel } from '../../../models/activitypub/actor' 6import { ActorModel } from '../../../models/activitypub/actor'
7import { areValidationErrors } from '../utils' 7import { areValidationErrors } from '../utils'
8 8
9const activityPubValidator = [ 9async 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