diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-06-01 01:36:53 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-06-02 16:57:07 +0200 |
commit | 76148b27f7501bac061992136852be4303370c8d (patch) | |
tree | fc0559253e833c9252fa14ebaec5321d88bfb4e8 /server/helpers/custom-validators/video-ownership.ts | |
parent | 5ed25fb76e920dac364cb9ef46f14ec4bd372949 (diff) | |
download | PeerTube-76148b27f7501bac061992136852be4303370c8d.tar.gz PeerTube-76148b27f7501bac061992136852be4303370c8d.tar.zst PeerTube-76148b27f7501bac061992136852be4303370c8d.zip |
refactor API errors to standard error format
Diffstat (limited to 'server/helpers/custom-validators/video-ownership.ts')
-rw-r--r-- | server/helpers/custom-validators/video-ownership.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/server/helpers/custom-validators/video-ownership.ts b/server/helpers/custom-validators/video-ownership.ts index ee3cebe10..21a6b7203 100644 --- a/server/helpers/custom-validators/video-ownership.ts +++ b/server/helpers/custom-validators/video-ownership.ts | |||
@@ -9,10 +9,10 @@ export async function doesChangeVideoOwnershipExist (idArg: number | string, res | |||
9 | const videoChangeOwnership = await VideoChangeOwnershipModel.load(id) | 9 | const videoChangeOwnership = await VideoChangeOwnershipModel.load(id) |
10 | 10 | ||
11 | if (!videoChangeOwnership) { | 11 | if (!videoChangeOwnership) { |
12 | res.status(HttpStatusCode.NOT_FOUND_404) | 12 | res.fail({ |
13 | .json({ error: 'Video change ownership not found' }) | 13 | status: HttpStatusCode.NOT_FOUND_404, |
14 | .end() | 14 | message: 'Video change ownership not found' |
15 | 15 | }) | |
16 | return false | 16 | return false |
17 | } | 17 | } |
18 | 18 | ||
@@ -25,8 +25,9 @@ export function checkUserCanTerminateOwnershipChange (user: MUserId, videoChange | |||
25 | return true | 25 | return true |
26 | } | 26 | } |
27 | 27 | ||
28 | res.status(HttpStatusCode.FORBIDDEN_403) | 28 | res.fail({ |
29 | .json({ error: 'Cannot terminate an ownership change of another user' }) | 29 | status: HttpStatusCode.FORBIDDEN_403, |
30 | .end() | 30 | message: 'Cannot terminate an ownership change of another user' |
31 | }) | ||
31 | return false | 32 | return false |
32 | } | 33 | } |