X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fsort.ts;h=77a532276d26de286b44ccb7c8700d82a4270504;hb=0c9668f77901e7540e2c7045eb0f2974a4842a69;hp=0600ccd15567fd74f37f8fb0049330fafcbdd2bf;hpb=5bcbcbe338ef5a1ed14f084311d013fbb25dabcf;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts index 0600ccd15..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') // ---------------------------------------------------------------------------