From 3866ea02d4a5c8e4c69a5d8633a883e3733414b9 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Tue, 1 Jun 2021 16:07:58 +0200 Subject: correct error codes and backward compat --- server/middlewares/validators/activitypub/activity.ts | 6 ++---- server/middlewares/validators/videos/video-live.ts | 4 ++-- server/middlewares/validators/videos/videos.ts | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts index 59355e855..cc6acd4b1 100644 --- a/server/middlewares/validators/activitypub/activity.ts +++ b/server/middlewares/validators/activitypub/activity.ts @@ -9,16 +9,14 @@ async function activityPubValidator (req: express.Request, res: express.Response if (!isRootActivityValid(req.body)) { logger.warn('Incorrect activity parameters.', { activity: req.body }) - return res.status(HttpStatusCode.BAD_REQUEST_400) - .end() + return res.fail({ message: 'Incorrect activity' }) } const serverActor = await getServerActor() const remoteActor = res.locals.signature.actor if (serverActor.id === remoteActor.id || remoteActor.serverId === null) { logger.error('Receiving request in INBOX by ourselves!', req.body) - return res.status(HttpStatusCode.CONFLICT_409) - .end() + return res.status(HttpStatusCode.CONFLICT_409).end() } return next() diff --git a/server/middlewares/validators/videos/video-live.ts b/server/middlewares/validators/videos/video-live.ts index 9544fa4f5..0fb864098 100644 --- a/server/middlewares/validators/videos/video-live.ts +++ b/server/middlewares/validators/videos/video-live.ts @@ -104,7 +104,7 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([ return res.fail({ status: HttpStatusCode.FORBIDDEN_403, message: 'Cannot create this live because the max instance lives limit is reached.', - type: ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED.toString() + type: ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED }) } } @@ -117,7 +117,7 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([ return res.fail({ status: HttpStatusCode.FORBIDDEN_403, - type: ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED.toString(), + type: ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED, message: 'Cannot create this live because the max user lives limit is reached.' }) } diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index dfd472400..fd0e543f1 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts @@ -253,7 +253,7 @@ async function checkVideoFollowConstraints (req: express.Request, res: express.R return res.fail({ status: HttpStatusCode.FORBIDDEN_403, message: 'Cannot get this video regarding follow constraints.', - type: ServerErrorCode.DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS.toString(), + type: ServerErrorCode.DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS, data: { originUrl: video.url } -- cgit v1.2.3