diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-10 22:15:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-10 22:15:25 +0200 |
commit | 69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch) | |
tree | ad199a18ec3c322460d6f9523fc383ee562554e0 /server/middlewares/validators | |
parent | 4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff) | |
download | PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.gz PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.zst PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.zip |
Type functions
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/pagination.ts | 5 | ||||
-rw-r--r-- | server/middlewares/validators/pods.ts | 7 | ||||
-rw-r--r-- | server/middlewares/validators/remote/signature.ts | 5 | ||||
-rw-r--r-- | server/middlewares/validators/remote/videos.ts | 9 | ||||
-rw-r--r-- | server/middlewares/validators/sort.ts | 13 | ||||
-rw-r--r-- | server/middlewares/validators/users.ts | 11 | ||||
-rw-r--r-- | server/middlewares/validators/utils.ts | 5 | ||||
-rw-r--r-- | server/middlewares/validators/videos.ts | 28 |
8 files changed, 53 insertions, 30 deletions
diff --git a/server/middlewares/validators/pagination.ts b/server/middlewares/validators/pagination.ts index de719c05b..cca8295ff 100644 --- a/server/middlewares/validators/pagination.ts +++ b/server/middlewares/validators/pagination.ts | |||
@@ -1,7 +1,10 @@ | |||
1 | import 'express-validator' | ||
2 | import * as express from 'express' | ||
3 | |||
1 | import { checkErrors } from './utils' | 4 | import { checkErrors } from './utils' |
2 | import { logger } from '../../helpers' | 5 | import { logger } from '../../helpers' |
3 | 6 | ||
4 | function paginationValidator (req, res, next) { | 7 | function paginationValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
5 | req.checkQuery('start', 'Should have a number start').optional().isInt() | 8 | req.checkQuery('start', 'Should have a number start').optional().isInt() |
6 | req.checkQuery('count', 'Should have a number count').optional().isInt() | 9 | req.checkQuery('count', 'Should have a number count').optional().isInt() |
7 | 10 | ||
diff --git a/server/middlewares/validators/pods.ts b/server/middlewares/validators/pods.ts index c55a88b85..d8eb90168 100644 --- a/server/middlewares/validators/pods.ts +++ b/server/middlewares/validators/pods.ts | |||
@@ -1,3 +1,6 @@ | |||
1 | import 'express-validator' | ||
2 | import * as express from 'express' | ||
3 | |||
1 | import { database as db } from '../../initializers/database' | 4 | import { database as db } from '../../initializers/database' |
2 | import { checkErrors } from './utils' | 5 | import { checkErrors } from './utils' |
3 | import { logger } from '../../helpers' | 6 | import { logger } from '../../helpers' |
@@ -5,7 +8,7 @@ import { CONFIG } from '../../initializers' | |||
5 | import { hasFriends } from '../../lib' | 8 | import { hasFriends } from '../../lib' |
6 | import { isTestInstance } from '../../helpers' | 9 | import { isTestInstance } from '../../helpers' |
7 | 10 | ||
8 | function makeFriendsValidator (req, res, next) { | 11 | function makeFriendsValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
9 | // Force https if the administrator wants to make friends | 12 | // Force https if the administrator wants to make friends |
10 | if (isTestInstance() === false && CONFIG.WEBSERVER.SCHEME === 'http') { | 13 | if (isTestInstance() === false && CONFIG.WEBSERVER.SCHEME === 'http') { |
11 | return res.status(400).send('Cannot make friends with a non HTTPS webserver.') | 14 | return res.status(400).send('Cannot make friends with a non HTTPS webserver.') |
@@ -32,7 +35,7 @@ function makeFriendsValidator (req, res, next) { | |||
32 | }) | 35 | }) |
33 | } | 36 | } |
34 | 37 | ||
35 | function podsAddValidator (req, res, next) { | 38 | function podsAddValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
36 | req.checkBody('host', 'Should have a host').isHostValid() | 39 | req.checkBody('host', 'Should have a host').isHostValid() |
37 | req.checkBody('email', 'Should have an email').isEmail() | 40 | req.checkBody('email', 'Should have an email').isEmail() |
38 | req.checkBody('publicKey', 'Should have a public key').notEmpty() | 41 | req.checkBody('publicKey', 'Should have a public key').notEmpty() |
diff --git a/server/middlewares/validators/remote/signature.ts b/server/middlewares/validators/remote/signature.ts index 6e3ebe7db..eb5c196eb 100644 --- a/server/middlewares/validators/remote/signature.ts +++ b/server/middlewares/validators/remote/signature.ts | |||
@@ -1,7 +1,10 @@ | |||
1 | import 'express-validator' | ||
2 | import * as express from 'express' | ||
3 | |||
1 | import { logger } from '../../../helpers' | 4 | import { logger } from '../../../helpers' |
2 | import { checkErrors } from '../utils' | 5 | import { checkErrors } from '../utils' |
3 | 6 | ||
4 | function signatureValidator (req, res, next) { | 7 | function signatureValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
5 | req.checkBody('signature.host', 'Should have a signature host').isURL() | 8 | req.checkBody('signature.host', 'Should have a signature host').isURL() |
6 | req.checkBody('signature.signature', 'Should have a signature').notEmpty() | 9 | req.checkBody('signature.signature', 'Should have a signature').notEmpty() |
7 | 10 | ||
diff --git a/server/middlewares/validators/remote/videos.ts b/server/middlewares/validators/remote/videos.ts index 3380c29e2..2037c0085 100644 --- a/server/middlewares/validators/remote/videos.ts +++ b/server/middlewares/validators/remote/videos.ts | |||
@@ -1,7 +1,10 @@ | |||
1 | import 'express-validator' | ||
2 | import * as express from 'express' | ||
3 | |||
1 | import { logger } from '../../../helpers' | 4 | import { logger } from '../../../helpers' |
2 | import { checkErrors } from '../utils' | 5 | import { checkErrors } from '../utils' |
3 | 6 | ||
4 | function remoteVideosValidator (req, res, next) { | 7 | function remoteVideosValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
5 | req.checkBody('data').isEachRemoteRequestVideosValid() | 8 | req.checkBody('data').isEachRemoteRequestVideosValid() |
6 | 9 | ||
7 | logger.debug('Checking remoteVideos parameters', { parameters: req.body }) | 10 | logger.debug('Checking remoteVideos parameters', { parameters: req.body }) |
@@ -9,7 +12,7 @@ function remoteVideosValidator (req, res, next) { | |||
9 | checkErrors(req, res, next) | 12 | checkErrors(req, res, next) |
10 | } | 13 | } |
11 | 14 | ||
12 | function remoteQaduVideosValidator (req, res, next) { | 15 | function remoteQaduVideosValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
13 | req.checkBody('data').isEachRemoteRequestVideosQaduValid() | 16 | req.checkBody('data').isEachRemoteRequestVideosQaduValid() |
14 | 17 | ||
15 | logger.debug('Checking remoteQaduVideos parameters', { parameters: req.body }) | 18 | logger.debug('Checking remoteQaduVideos parameters', { parameters: req.body }) |
@@ -17,7 +20,7 @@ function remoteQaduVideosValidator (req, res, next) { | |||
17 | checkErrors(req, res, next) | 20 | checkErrors(req, res, next) |
18 | } | 21 | } |
19 | 22 | ||
20 | function remoteEventsVideosValidator (req, res, next) { | 23 | function remoteEventsVideosValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
21 | req.checkBody('data').isEachRemoteRequestVideosEventsValid() | 24 | req.checkBody('data').isEachRemoteRequestVideosEventsValid() |
22 | 25 | ||
23 | logger.debug('Checking remoteEventsVideos parameters', { parameters: req.body }) | 26 | logger.debug('Checking remoteEventsVideos parameters', { parameters: req.body }) |
diff --git a/server/middlewares/validators/sort.ts b/server/middlewares/validators/sort.ts index ebc7333c7..3baee9fb3 100644 --- a/server/middlewares/validators/sort.ts +++ b/server/middlewares/validators/sort.ts | |||
@@ -1,3 +1,6 @@ | |||
1 | import 'express-validator' | ||
2 | import * as express from 'express' | ||
3 | |||
1 | import { checkErrors } from './utils' | 4 | import { checkErrors } from './utils' |
2 | import { logger } from '../../helpers' | 5 | import { logger } from '../../helpers' |
3 | import { SORTABLE_COLUMNS } from '../../initializers' | 6 | import { SORTABLE_COLUMNS } from '../../initializers' |
@@ -7,15 +10,15 @@ const SORTABLE_USERS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USERS) | |||
7 | const SORTABLE_VIDEO_ABUSES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_ABUSES) | 10 | const SORTABLE_VIDEO_ABUSES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_ABUSES) |
8 | const SORTABLE_VIDEOS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS) | 11 | const SORTABLE_VIDEOS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS) |
9 | 12 | ||
10 | function usersSortValidator (req, res, next) { | 13 | function usersSortValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
11 | checkSort(req, res, next, SORTABLE_USERS_COLUMNS) | 14 | checkSort(req, res, next, SORTABLE_USERS_COLUMNS) |
12 | } | 15 | } |
13 | 16 | ||
14 | function videoAbusesSortValidator (req, res, next) { | 17 | function videoAbusesSortValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
15 | checkSort(req, res, next, SORTABLE_VIDEO_ABUSES_COLUMNS) | 18 | checkSort(req, res, next, SORTABLE_VIDEO_ABUSES_COLUMNS) |
16 | } | 19 | } |
17 | 20 | ||
18 | function videosSortValidator (req, res, next) { | 21 | function videosSortValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
19 | checkSort(req, res, next, SORTABLE_VIDEOS_COLUMNS) | 22 | checkSort(req, res, next, SORTABLE_VIDEOS_COLUMNS) |
20 | } | 23 | } |
21 | 24 | ||
@@ -29,7 +32,7 @@ export { | |||
29 | 32 | ||
30 | // --------------------------------------------------------------------------- | 33 | // --------------------------------------------------------------------------- |
31 | 34 | ||
32 | function checkSort (req, res, next, sortableColumns) { | 35 | function checkSort (req: express.Request, res: express.Response, next: express.NextFunction, sortableColumns: string[]) { |
33 | req.checkQuery('sort', 'Should have correct sortable column').optional().isIn(sortableColumns) | 36 | req.checkQuery('sort', 'Should have correct sortable column').optional().isIn(sortableColumns) |
34 | 37 | ||
35 | logger.debug('Checking sort parameters', { parameters: req.query }) | 38 | logger.debug('Checking sort parameters', { parameters: req.query }) |
@@ -37,7 +40,7 @@ function checkSort (req, res, next, sortableColumns) { | |||
37 | checkErrors(req, res, next) | 40 | checkErrors(req, res, next) |
38 | } | 41 | } |
39 | 42 | ||
40 | function createSortableColumns (sortableColumns) { | 43 | function createSortableColumns (sortableColumns: string[]) { |
41 | const sortableColumnDesc = sortableColumns.map(sortableColumn => '-' + sortableColumn) | 44 | const sortableColumnDesc = sortableColumns.map(sortableColumn => '-' + sortableColumn) |
42 | 45 | ||
43 | return sortableColumns.concat(sortableColumnDesc) | 46 | return sortableColumns.concat(sortableColumnDesc) |
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index e0d1d917a..b7b9ef370 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -1,8 +1,11 @@ | |||
1 | import 'express-validator' | ||
2 | import * as express from 'express' | ||
3 | |||
1 | import { database as db } from '../../initializers/database' | 4 | import { database as db } from '../../initializers/database' |
2 | import { checkErrors } from './utils' | 5 | import { checkErrors } from './utils' |
3 | import { logger } from '../../helpers' | 6 | import { logger } from '../../helpers' |
4 | 7 | ||
5 | function usersAddValidator (req, res, next) { | 8 | function usersAddValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
6 | req.checkBody('username', 'Should have a valid username').isUserUsernameValid() | 9 | req.checkBody('username', 'Should have a valid username').isUserUsernameValid() |
7 | req.checkBody('password', 'Should have a valid password').isUserPasswordValid() | 10 | req.checkBody('password', 'Should have a valid password').isUserPasswordValid() |
8 | req.checkBody('email', 'Should have a valid email').isEmail() | 11 | req.checkBody('email', 'Should have a valid email').isEmail() |
@@ -23,7 +26,7 @@ function usersAddValidator (req, res, next) { | |||
23 | }) | 26 | }) |
24 | } | 27 | } |
25 | 28 | ||
26 | function usersRemoveValidator (req, res, next) { | 29 | function usersRemoveValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
27 | req.checkParams('id', 'Should have a valid id').notEmpty().isInt() | 30 | req.checkParams('id', 'Should have a valid id').notEmpty().isInt() |
28 | 31 | ||
29 | logger.debug('Checking usersRemove parameters', { parameters: req.params }) | 32 | logger.debug('Checking usersRemove parameters', { parameters: req.params }) |
@@ -44,7 +47,7 @@ function usersRemoveValidator (req, res, next) { | |||
44 | }) | 47 | }) |
45 | } | 48 | } |
46 | 49 | ||
47 | function usersUpdateValidator (req, res, next) { | 50 | function usersUpdateValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
48 | req.checkParams('id', 'Should have a valid id').notEmpty().isInt() | 51 | req.checkParams('id', 'Should have a valid id').notEmpty().isInt() |
49 | // Add old password verification | 52 | // Add old password verification |
50 | req.checkBody('password', 'Should have a valid password').optional().isUserPasswordValid() | 53 | req.checkBody('password', 'Should have a valid password').optional().isUserPasswordValid() |
@@ -55,7 +58,7 @@ function usersUpdateValidator (req, res, next) { | |||
55 | checkErrors(req, res, next) | 58 | checkErrors(req, res, next) |
56 | } | 59 | } |
57 | 60 | ||
58 | function usersVideoRatingValidator (req, res, next) { | 61 | function usersVideoRatingValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
59 | req.checkParams('videoId', 'Should have a valid video id').notEmpty().isUUID(4) | 62 | req.checkParams('videoId', 'Should have a valid video id').notEmpty().isUUID(4) |
60 | 63 | ||
61 | logger.debug('Checking usersVideoRating parameters', { parameters: req.params }) | 64 | logger.debug('Checking usersVideoRating parameters', { parameters: req.params }) |
diff --git a/server/middlewares/validators/utils.ts b/server/middlewares/validators/utils.ts index 710e65529..0424d5942 100644 --- a/server/middlewares/validators/utils.ts +++ b/server/middlewares/validators/utils.ts | |||
@@ -1,9 +1,10 @@ | |||
1 | import 'express-validator' | ||
2 | import * as express from 'express' | ||
1 | import { inspect } from 'util' | 3 | import { inspect } from 'util' |
2 | 4 | ||
3 | import { logger } from '../../helpers' | 5 | import { logger } from '../../helpers' |
4 | 6 | ||
5 | function checkErrors (req, res, next, statusCode?) { | 7 | function checkErrors (req: express.Request, res: express.Response, next: express.NextFunction, statusCode = 400) { |
6 | if (statusCode === undefined) statusCode = 400 | ||
7 | const errors = req.validationErrors() | 8 | const errors = req.validationErrors() |
8 | 9 | ||
9 | if (errors) { | 10 | if (errors) { |
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts index 47825975c..e99cdefb1 100644 --- a/server/middlewares/validators/videos.ts +++ b/server/middlewares/validators/videos.ts | |||
@@ -1,9 +1,13 @@ | |||
1 | import 'express-validator' | ||
2 | import * as multer from 'multer' | ||
3 | import * as express from 'express' | ||
4 | |||
1 | import { database as db } from '../../initializers/database' | 5 | import { database as db } from '../../initializers/database' |
2 | import { checkErrors } from './utils' | 6 | import { checkErrors } from './utils' |
3 | import { CONSTRAINTS_FIELDS, SEARCHABLE_COLUMNS } from '../../initializers' | 7 | import { CONSTRAINTS_FIELDS, SEARCHABLE_COLUMNS } from '../../initializers' |
4 | import { logger, isVideoDurationValid } from '../../helpers' | 8 | import { logger, isVideoDurationValid } from '../../helpers' |
5 | 9 | ||
6 | function videosAddValidator (req, res, next) { | 10 | function videosAddValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
7 | req.checkBody('videofile', 'Should have a valid file').isVideoFile(req.files) | 11 | req.checkBody('videofile', 'Should have a valid file').isVideoFile(req.files) |
8 | req.checkBody('name', 'Should have a valid name').isVideoNameValid() | 12 | req.checkBody('name', 'Should have a valid name').isVideoNameValid() |
9 | req.checkBody('category', 'Should have a valid category').isVideoCategoryValid() | 13 | req.checkBody('category', 'Should have a valid category').isVideoCategoryValid() |
@@ -27,13 +31,13 @@ function videosAddValidator (req, res, next) { | |||
27 | return res.status(400).send('Duration of the video file is too big (max: ' + CONSTRAINTS_FIELDS.VIDEOS.DURATION.max + 's).') | 31 | return res.status(400).send('Duration of the video file is too big (max: ' + CONSTRAINTS_FIELDS.VIDEOS.DURATION.max + 's).') |
28 | } | 32 | } |
29 | 33 | ||
30 | videoFile.duration = duration | 34 | videoFile['duration'] = duration |
31 | next() | 35 | next() |
32 | }) | 36 | }) |
33 | }) | 37 | }) |
34 | } | 38 | } |
35 | 39 | ||
36 | function videosUpdateValidator (req, res, next) { | 40 | function videosUpdateValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
37 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) | 41 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) |
38 | req.checkBody('name', 'Should have a valid name').optional().isVideoNameValid() | 42 | req.checkBody('name', 'Should have a valid name').optional().isVideoNameValid() |
39 | req.checkBody('category', 'Should have a valid category').optional().isVideoCategoryValid() | 43 | req.checkBody('category', 'Should have a valid category').optional().isVideoCategoryValid() |
@@ -61,7 +65,7 @@ function videosUpdateValidator (req, res, next) { | |||
61 | }) | 65 | }) |
62 | } | 66 | } |
63 | 67 | ||
64 | function videosGetValidator (req, res, next) { | 68 | function videosGetValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
65 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) | 69 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) |
66 | 70 | ||
67 | logger.debug('Checking videosGet parameters', { parameters: req.params }) | 71 | logger.debug('Checking videosGet parameters', { parameters: req.params }) |
@@ -71,7 +75,7 @@ function videosGetValidator (req, res, next) { | |||
71 | }) | 75 | }) |
72 | } | 76 | } |
73 | 77 | ||
74 | function videosRemoveValidator (req, res, next) { | 78 | function videosRemoveValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
75 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) | 79 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) |
76 | 80 | ||
77 | logger.debug('Checking videosRemove parameters', { parameters: req.params }) | 81 | logger.debug('Checking videosRemove parameters', { parameters: req.params }) |
@@ -88,7 +92,7 @@ function videosRemoveValidator (req, res, next) { | |||
88 | }) | 92 | }) |
89 | } | 93 | } |
90 | 94 | ||
91 | function videosSearchValidator (req, res, next) { | 95 | function videosSearchValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
92 | const searchableColumns = SEARCHABLE_COLUMNS.VIDEOS | 96 | const searchableColumns = SEARCHABLE_COLUMNS.VIDEOS |
93 | req.checkParams('value', 'Should have a valid search').notEmpty() | 97 | req.checkParams('value', 'Should have a valid search').notEmpty() |
94 | req.checkQuery('field', 'Should have correct searchable column').optional().isIn(searchableColumns) | 98 | req.checkQuery('field', 'Should have correct searchable column').optional().isIn(searchableColumns) |
@@ -98,7 +102,7 @@ function videosSearchValidator (req, res, next) { | |||
98 | checkErrors(req, res, next) | 102 | checkErrors(req, res, next) |
99 | } | 103 | } |
100 | 104 | ||
101 | function videoAbuseReportValidator (req, res, next) { | 105 | function videoAbuseReportValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
102 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) | 106 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) |
103 | req.checkBody('reason', 'Should have a valid reason').isVideoAbuseReasonValid() | 107 | req.checkBody('reason', 'Should have a valid reason').isVideoAbuseReasonValid() |
104 | 108 | ||
@@ -109,7 +113,7 @@ function videoAbuseReportValidator (req, res, next) { | |||
109 | }) | 113 | }) |
110 | } | 114 | } |
111 | 115 | ||
112 | function videoRateValidator (req, res, next) { | 116 | function videoRateValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
113 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) | 117 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) |
114 | req.checkBody('rating', 'Should have a valid rate type').isVideoRatingTypeValid() | 118 | req.checkBody('rating', 'Should have a valid rate type').isVideoRatingTypeValid() |
115 | 119 | ||
@@ -120,7 +124,7 @@ function videoRateValidator (req, res, next) { | |||
120 | }) | 124 | }) |
121 | } | 125 | } |
122 | 126 | ||
123 | function videosBlacklistValidator (req, res, next) { | 127 | function videosBlacklistValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
124 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) | 128 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) |
125 | 129 | ||
126 | logger.debug('Checking videosBlacklist parameters', { parameters: req.params }) | 130 | logger.debug('Checking videosBlacklist parameters', { parameters: req.params }) |
@@ -150,7 +154,7 @@ export { | |||
150 | 154 | ||
151 | // --------------------------------------------------------------------------- | 155 | // --------------------------------------------------------------------------- |
152 | 156 | ||
153 | function checkVideoExists (id, res, callback) { | 157 | function checkVideoExists (id: string, res: express.Response, callback: () => void) { |
154 | db.Video.loadAndPopulateAuthorAndPodAndTags(id, function (err, video) { | 158 | db.Video.loadAndPopulateAuthorAndPodAndTags(id, function (err, video) { |
155 | if (err) { | 159 | if (err) { |
156 | logger.error('Error in video request validator.', { error: err }) | 160 | logger.error('Error in video request validator.', { error: err }) |
@@ -164,7 +168,7 @@ function checkVideoExists (id, res, callback) { | |||
164 | }) | 168 | }) |
165 | } | 169 | } |
166 | 170 | ||
167 | function checkUserCanDeleteVideo (userId, res, callback) { | 171 | function checkUserCanDeleteVideo (userId: number, res: express.Response, callback: () => void) { |
168 | // Retrieve the user who did the request | 172 | // Retrieve the user who did the request |
169 | db.User.loadById(userId, function (err, user) { | 173 | db.User.loadById(userId, function (err, user) { |
170 | if (err) { | 174 | if (err) { |
@@ -190,7 +194,7 @@ function checkUserCanDeleteVideo (userId, res, callback) { | |||
190 | }) | 194 | }) |
191 | } | 195 | } |
192 | 196 | ||
193 | function checkVideoIsBlacklistable (req, res, callback) { | 197 | function checkVideoIsBlacklistable (req: express.Request, res: express.Response, callback: () => void) { |
194 | if (res.locals.video.isOwned() === true) { | 198 | if (res.locals.video.isOwned() === true) { |
195 | return res.status(403).send('Cannot blacklist a local video') | 199 | return res.status(403).send('Cannot blacklist a local video') |
196 | } | 200 | } |