diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-30 10:51:13 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-30 10:55:06 +0100 |
commit | 5cd80545422bba855cc9a730a2e13cc9d982c34b (patch) | |
tree | 9a60cd7c9218c296a1460938d11e3bce784f7cc0 /server/middlewares | |
parent | 1f3e9feca2caf68024168b0ea9ed39d8438fa235 (diff) | |
download | PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.tar.gz PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.tar.zst PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.zip |
Add ability to list jobs
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/sort.ts | 9 | ||||
-rw-r--r-- | server/middlewares/validators/sort.ts | 5 |
2 files changed, 12 insertions, 2 deletions
diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts index 279b29e65..7b60920de 100644 --- a/server/middlewares/sort.ts +++ b/server/middlewares/sort.ts | |||
@@ -10,6 +10,12 @@ function setUsersSort (req: express.Request, res: express.Response, next: expres | |||
10 | return next() | 10 | return next() |
11 | } | 11 | } |
12 | 12 | ||
13 | function setJobsSort (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
14 | if (!req.query.sort) req.query.sort = '-createdAt' | ||
15 | |||
16 | return next() | ||
17 | } | ||
18 | |||
13 | function setVideoAbusesSort (req: express.Request, res: express.Response, next: express.NextFunction) { | 19 | function setVideoAbusesSort (req: express.Request, res: express.Response, next: express.NextFunction) { |
14 | if (!req.query.sort) req.query.sort = '-createdAt' | 20 | if (!req.query.sort) req.query.sort = '-createdAt' |
15 | 21 | ||
@@ -70,5 +76,6 @@ export { | |||
70 | setVideosSort, | 76 | setVideosSort, |
71 | setBlacklistSort, | 77 | setBlacklistSort, |
72 | setFollowersSort, | 78 | setFollowersSort, |
73 | setFollowingSort | 79 | setFollowingSort, |
80 | setJobsSort | ||
74 | } | 81 | } |
diff --git a/server/middlewares/validators/sort.ts b/server/middlewares/validators/sort.ts index 636f68885..d5822ac81 100644 --- a/server/middlewares/validators/sort.ts +++ b/server/middlewares/validators/sort.ts | |||
@@ -7,6 +7,7 @@ import { areValidationErrors } from './utils' | |||
7 | 7 | ||
8 | // Initialize constants here for better performances | 8 | // Initialize constants here for better performances |
9 | const SORTABLE_USERS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USERS) | 9 | const SORTABLE_USERS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USERS) |
10 | const SORTABLE_JOBS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.JOBS) | ||
10 | const SORTABLE_VIDEO_ABUSES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_ABUSES) | 11 | const SORTABLE_VIDEO_ABUSES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_ABUSES) |
11 | const SORTABLE_VIDEOS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS) | 12 | const SORTABLE_VIDEOS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS) |
12 | const SORTABLE_BLACKLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.BLACKLISTS) | 13 | const SORTABLE_BLACKLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.BLACKLISTS) |
@@ -15,6 +16,7 @@ const SORTABLE_FOLLOWERS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.FOLLOW | |||
15 | const SORTABLE_FOLLOWING_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.FOLLOWING) | 16 | const SORTABLE_FOLLOWING_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.FOLLOWING) |
16 | 17 | ||
17 | const usersSortValidator = checkSort(SORTABLE_USERS_COLUMNS) | 18 | const usersSortValidator = checkSort(SORTABLE_USERS_COLUMNS) |
19 | const jobsSortValidator = checkSort(SORTABLE_JOBS_COLUMNS) | ||
18 | const videoAbusesSortValidator = checkSort(SORTABLE_VIDEO_ABUSES_COLUMNS) | 20 | const videoAbusesSortValidator = checkSort(SORTABLE_VIDEO_ABUSES_COLUMNS) |
19 | const videosSortValidator = checkSort(SORTABLE_VIDEOS_COLUMNS) | 21 | const videosSortValidator = checkSort(SORTABLE_VIDEOS_COLUMNS) |
20 | const blacklistSortValidator = checkSort(SORTABLE_BLACKLISTS_COLUMNS) | 22 | const blacklistSortValidator = checkSort(SORTABLE_BLACKLISTS_COLUMNS) |
@@ -31,7 +33,8 @@ export { | |||
31 | videosSortValidator, | 33 | videosSortValidator, |
32 | blacklistSortValidator, | 34 | blacklistSortValidator, |
33 | followersSortValidator, | 35 | followersSortValidator, |
34 | followingSortValidator | 36 | followingSortValidator, |
37 | jobsSortValidator | ||
35 | } | 38 | } |
36 | 39 | ||
37 | // --------------------------------------------------------------------------- | 40 | // --------------------------------------------------------------------------- |