X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fsort.ts;h=cdb809e75e80084d5f6774e4f21ba4159be89fee;hb=1174a8479ab9ee47b3305d668fe757435057a298;hp=2c70ff5f0b2e5ecbb0eb940710ba13babc1c1a3e;hpb=8a02bd0433b7101c5ea36e87a4edb63204d2adec;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts index 2c70ff5f0..cdb809e75 100644 --- a/server/middlewares/sort.ts +++ b/server/middlewares/sort.ts @@ -1,28 +1,8 @@ -import 'express-validator' import * as express from 'express' +import 'express-validator' +import { SortType } from '../helpers/utils' -import { SortType } from '../helpers' -import { database } from '../initializers' - -function setPodsSort (req: express.Request, res: express.Response, next: express.NextFunction) { - if (!req.query.sort) req.query.sort = '-createdAt' - - return next() -} - -function setUsersSort (req: express.Request, res: express.Response, next: express.NextFunction) { - if (!req.query.sort) req.query.sort = '-createdAt' - - return next() -} - -function setVideoAbusesSort (req: express.Request, res: express.Response, next: express.NextFunction) { - if (!req.query.sort) req.query.sort = '-createdAt' - - return next() -} - -function setVideosSort (req: express.Request, res: express.Response, next: express.NextFunction) { +function setDefaultSort (req: express.Request, res: express.Response, next: express.NextFunction) { if (!req.query.sort) req.query.sort = '-createdAt' return next() @@ -39,7 +19,7 @@ function setBlacklistSort (req: express.Request, res: express.Response, next: ex // If we want to sort onto the BlacklistedVideos relation, we won't specify it in the query parameter ... newSort.sortModel = undefined } else { - newSort.sortModel = database.Video + newSort.sortModel = 'Video' } newSort.sortValue = req.query.sort @@ -52,9 +32,6 @@ function setBlacklistSort (req: express.Request, res: express.Response, next: ex // --------------------------------------------------------------------------- export { - setPodsSort, - setUsersSort, - setVideoAbusesSort, - setVideosSort, + setDefaultSort, setBlacklistSort }