diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-06-01 16:07:58 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-06-02 16:57:07 +0200 |
commit | 3866ea02d4a5c8e4c69a5d8633a883e3733414b9 (patch) | |
tree | ac484fcf59a257ce526888a6b1d4cb8f61b4a49a /server/middlewares | |
parent | 1cfbdd30d9913bfaa0c7e54f82e5b953646bb0d1 (diff) | |
download | PeerTube-3866ea02d4a5c8e4c69a5d8633a883e3733414b9.tar.gz PeerTube-3866ea02d4a5c8e4c69a5d8633a883e3733414b9.tar.zst PeerTube-3866ea02d4a5c8e4c69a5d8633a883e3733414b9.zip |
correct error codes and backward compat
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/activitypub/activity.ts | 6 | ||||
-rw-r--r-- | server/middlewares/validators/videos/video-live.ts | 4 | ||||
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 2 |
3 files changed, 5 insertions, 7 deletions
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 | |||
9 | 9 | ||
10 | if (!isRootActivityValid(req.body)) { | 10 | if (!isRootActivityValid(req.body)) { |
11 | logger.warn('Incorrect activity parameters.', { activity: req.body }) | 11 | logger.warn('Incorrect activity parameters.', { activity: req.body }) |
12 | return res.status(HttpStatusCode.BAD_REQUEST_400) | 12 | return res.fail({ message: 'Incorrect activity' }) |
13 | .end() | ||
14 | } | 13 | } |
15 | 14 | ||
16 | const serverActor = await getServerActor() | 15 | const serverActor = await getServerActor() |
17 | const remoteActor = res.locals.signature.actor | 16 | const remoteActor = res.locals.signature.actor |
18 | if (serverActor.id === remoteActor.id || remoteActor.serverId === null) { | 17 | if (serverActor.id === remoteActor.id || remoteActor.serverId === null) { |
19 | logger.error('Receiving request in INBOX by ourselves!', req.body) | 18 | logger.error('Receiving request in INBOX by ourselves!', req.body) |
20 | return res.status(HttpStatusCode.CONFLICT_409) | 19 | return res.status(HttpStatusCode.CONFLICT_409).end() |
21 | .end() | ||
22 | } | 20 | } |
23 | 21 | ||
24 | return next() | 22 | 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([ | |||
104 | return res.fail({ | 104 | return res.fail({ |
105 | status: HttpStatusCode.FORBIDDEN_403, | 105 | status: HttpStatusCode.FORBIDDEN_403, |
106 | message: 'Cannot create this live because the max instance lives limit is reached.', | 106 | message: 'Cannot create this live because the max instance lives limit is reached.', |
107 | type: ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED.toString() | 107 | type: ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED |
108 | }) | 108 | }) |
109 | } | 109 | } |
110 | } | 110 | } |
@@ -117,7 +117,7 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([ | |||
117 | 117 | ||
118 | return res.fail({ | 118 | return res.fail({ |
119 | status: HttpStatusCode.FORBIDDEN_403, | 119 | status: HttpStatusCode.FORBIDDEN_403, |
120 | type: ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED.toString(), | 120 | type: ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED, |
121 | message: 'Cannot create this live because the max user lives limit is reached.' | 121 | message: 'Cannot create this live because the max user lives limit is reached.' |
122 | }) | 122 | }) |
123 | } | 123 | } |
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 | |||
253 | return res.fail({ | 253 | return res.fail({ |
254 | status: HttpStatusCode.FORBIDDEN_403, | 254 | status: HttpStatusCode.FORBIDDEN_403, |
255 | message: 'Cannot get this video regarding follow constraints.', | 255 | message: 'Cannot get this video regarding follow constraints.', |
256 | type: ServerErrorCode.DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS.toString(), | 256 | type: ServerErrorCode.DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS, |
257 | data: { | 257 | data: { |
258 | originUrl: video.url | 258 | originUrl: video.url |
259 | } | 259 | } |