X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fsort.ts;h=cdb809e75e80084d5f6774e4f21ba4159be89fee;hb=48dce1c90dff4e90a4bcffefaecf157336cf904b;hp=91aa3e5b6b4c2ac38d7f1a330dd8ca9f36aac8f3;hpb=72c7248b6fdcdb2175e726ff51b42e7555f2bd84;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts index 91aa3e5b6..cdb809e75 100644 --- a/server/middlewares/sort.ts +++ b/server/middlewares/sort.ts @@ -1,34 +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 setVideoChannelsSort (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() @@ -45,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 @@ -58,10 +32,6 @@ function setBlacklistSort (req: express.Request, res: express.Response, next: ex // --------------------------------------------------------------------------- export { - setPodsSort, - setUsersSort, - setVideoAbusesSort, - setVideoChannelsSort, - setVideosSort, + setDefaultSort, setBlacklistSort }