X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fusers%2Fmy-history.ts;h=cff1697ab719320ba07ad5b54708011f5ec8cccf;hb=1c5e49e75284100b7b1fc8b4e73c8ba53fe22e89;hp=b30d3aec2bd6383755e0cf22161c8e3a5a25438a;hpb=dae86118ed5d4026d04acb9d0e36829b9ad8eb4e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/users/my-history.ts b/server/controllers/api/users/my-history.ts index b30d3aec2..cff1697ab 100644 --- a/server/controllers/api/users/my-history.ts +++ b/server/controllers/api/users/my-history.ts @@ -5,12 +5,13 @@ import { authenticate, paginationValidator, setDefaultPagination, + userHistoryListValidator, userHistoryRemoveValidator } from '../../../middlewares' -import { UserModel } from '../../../models/account/user' import { getFormattedObjects } from '../../../helpers/utils' -import { UserVideoHistoryModel } from '../../../models/account/user-video-history' -import { sequelizeTypescript } from '../../../initializers' +import { UserVideoHistoryModel } from '../../../models/user/user-video-history' +import { sequelizeTypescript } from '../../../initializers/database' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const myVideosHistoryRouter = express.Router() @@ -18,6 +19,7 @@ myVideosHistoryRouter.get('/me/history/videos', authenticate, paginationValidator, setDefaultPagination, + userHistoryListValidator, asyncMiddleware(listMyVideosHistory) ) @@ -38,7 +40,7 @@ export { async function listMyVideosHistory (req: express.Request, res: express.Response) { const user = res.locals.oauth.token.User - const resultList = await UserVideoHistoryModel.listForApi(user, req.query.start, req.query.count) + const resultList = await UserVideoHistoryModel.listForApi(user, req.query.start, req.query.count, req.query.search) return res.json(getFormattedObjects(resultList.data, resultList.total)) } @@ -48,10 +50,10 @@ async function removeUserHistory (req: express.Request, res: express.Response) { const beforeDate = req.body.beforeDate || null await sequelizeTypescript.transaction(t => { - return UserVideoHistoryModel.removeHistoryBefore(user, beforeDate, t) + return UserVideoHistoryModel.removeUserHistoryBefore(user, beforeDate, t) }) - // Do not send the delete to other instances, we delete OUR copy of this video abuse - - return res.type('json').status(204).end() + return res.type('json') + .status(HttpStatusCode.NO_CONTENT_204) + .end() }