X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fsort.ts;h=77a532276d26de286b44ccb7c8700d82a4270504;hb=43dd28772a10daba5488be4bd700b24469c153b0;hp=609046a4627cc8367b134f9ff1aaeb2e27bb5025;hpb=8054669f1181e815c435e76e81247eff32d41dc5;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts index 609046a46..77a532276 100644 --- a/server/middlewares/sort.ts +++ b/server/middlewares/sort.ts @@ -1,5 +1,4 @@ -import * as express from 'express' -import { SortType } from '../models/utils' +import express from 'express' const setDefaultSort = setDefaultSortFactory('-createdAt') const setDefaultVideosSort = setDefaultSortFactory('-publishedAt') @@ -7,27 +6,7 @@ const setDefaultVideosSort = setDefaultSortFactory('-publishedAt') const setDefaultVideoRedundanciesSort = setDefaultSortFactory('name') const setDefaultSearchSort = setDefaultSortFactory('-match') - -function setBlacklistSort (req: express.Request, res: express.Response, next: express.NextFunction) { - const newSort: SortType = { sortModel: undefined, sortValue: '' } - - if (!req.query.sort) req.query.sort = '-createdAt' - - // Set model we want to sort onto - if (req.query.sort === '-createdAt' || req.query.sort === 'createdAt' || - req.query.sort === '-id' || req.query.sort === 'id') { - // If we want to sort onto the BlacklistedVideos relation, we won't specify it in the query parameter ... - newSort.sortModel = undefined - } else { - newSort.sortModel = 'Video' - } - - newSort.sortValue = req.query.sort - - req.query.sort = newSort - - return next() -} +const setBlacklistSort = setDefaultSortFactory('-createdAt') // ---------------------------------------------------------------------------