]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/sort.ts
Fix error logging
[github/Chocobozzz/PeerTube.git] / server / middlewares / sort.ts
index 687ce097b7c8b2f32702df186fd63e8ceb7c1a94..cdb809e75e80084d5f6774e4f21ba4159be89fee 100644 (file)
@@ -1,22 +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 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()
@@ -33,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
@@ -46,8 +32,6 @@ function setBlacklistSort (req: express.Request, res: express.Response, next: ex
 // ---------------------------------------------------------------------------
 
 export {
-  setUsersSort,
-  setVideoAbusesSort,
-  setVideosSort,
+  setDefaultSort,
   setBlacklistSort
 }