mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
replace numbers with typed http status codes (#3409)
This commit is contained in:
parent
adc1f09c0d
commit
2d53be0267
149 changed files with 1721 additions and 1108 deletions
|
@ -2,20 +2,23 @@ import * as express from 'express'
|
|||
import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
async function activityPubValidator (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
logger.debug('Checking activity pub parameters')
|
||||
|
||||
if (!isRootActivityValid(req.body)) {
|
||||
logger.warn('Incorrect activity parameters.', { activity: req.body })
|
||||
return res.status(400).json({ error: 'Incorrect activity.' })
|
||||
return res.status(HttpStatusCode.BAD_REQUEST_400)
|
||||
.json({ error: 'Incorrect activity.' })
|
||||
}
|
||||
|
||||
const serverActor = await getServerActor()
|
||||
const remoteActor = res.locals.signature.actor
|
||||
if (serverActor.id === remoteActor.id) {
|
||||
logger.error('Receiving request in INBOX by ourselves!', req.body)
|
||||
return res.status(409).end()
|
||||
return res.status(HttpStatusCode.CONFLICT_409)
|
||||
.end()
|
||||
}
|
||||
|
||||
return next()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue