diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-12-07 14:32:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 14:32:36 +0100 |
commit | 2d53be0267acc49cda46707b885096193a1f4e9c (patch) | |
tree | 887061a34bc67f40acbb96a6278f9544bf83caeb /server/helpers/custom-validators/video-ownership.ts | |
parent | adc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff) | |
download | PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip |
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'server/helpers/custom-validators/video-ownership.ts')
-rw-r--r-- | server/helpers/custom-validators/video-ownership.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/video-ownership.ts b/server/helpers/custom-validators/video-ownership.ts index ed5f8cc2f..ee3cebe10 100644 --- a/server/helpers/custom-validators/video-ownership.ts +++ b/server/helpers/custom-validators/video-ownership.ts | |||
@@ -2,13 +2,14 @@ import { Response } from 'express' | |||
2 | import { VideoChangeOwnershipModel } from '../../models/video/video-change-ownership' | 2 | import { VideoChangeOwnershipModel } from '../../models/video/video-change-ownership' |
3 | import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership' | 3 | import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership' |
4 | import { MUserId } from '@server/types/models' | 4 | import { MUserId } from '@server/types/models' |
5 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
5 | 6 | ||
6 | export async function doesChangeVideoOwnershipExist (idArg: number | string, res: Response) { | 7 | export async function doesChangeVideoOwnershipExist (idArg: number | string, res: Response) { |
7 | const id = parseInt(idArg + '', 10) | 8 | const id = parseInt(idArg + '', 10) |
8 | const videoChangeOwnership = await VideoChangeOwnershipModel.load(id) | 9 | const videoChangeOwnership = await VideoChangeOwnershipModel.load(id) |
9 | 10 | ||
10 | if (!videoChangeOwnership) { | 11 | if (!videoChangeOwnership) { |
11 | res.status(404) | 12 | res.status(HttpStatusCode.NOT_FOUND_404) |
12 | .json({ error: 'Video change ownership not found' }) | 13 | .json({ error: 'Video change ownership not found' }) |
13 | .end() | 14 | .end() |
14 | 15 | ||
@@ -24,7 +25,7 @@ export function checkUserCanTerminateOwnershipChange (user: MUserId, videoChange | |||
24 | return true | 25 | return true |
25 | } | 26 | } |
26 | 27 | ||
27 | res.status(403) | 28 | res.status(HttpStatusCode.FORBIDDEN_403) |
28 | .json({ error: 'Cannot terminate an ownership change of another user' }) | 29 | .json({ error: 'Cannot terminate an ownership change of another user' }) |
29 | .end() | 30 | .end() |
30 | return false | 31 | return false |