From 7ad9b9846c44d198a736183fb186c2039f5236b5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 12 Oct 2018 15:26:04 +0200 Subject: Add ability for users to block an account/instance on server side --- server/controllers/api/videos/comment.ts | 12 +++++++++--- server/controllers/api/videos/index.ts | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'server/controllers/api/videos') diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index 4f2b4faee..3875c8f79 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts @@ -8,7 +8,7 @@ import { buildFormattedCommentTree, createVideoComment } from '../../../lib/vide import { asyncMiddleware, asyncRetryTransactionMiddleware, - authenticate, + authenticate, optionalAuthenticate, paginationValidator, setDefaultPagination, setDefaultSort @@ -36,10 +36,12 @@ videoCommentRouter.get('/:videoId/comment-threads', setDefaultSort, setDefaultPagination, asyncMiddleware(listVideoCommentThreadsValidator), + optionalAuthenticate, asyncMiddleware(listVideoThreads) ) videoCommentRouter.get('/:videoId/comment-threads/:threadId', asyncMiddleware(listVideoThreadCommentsValidator), + optionalAuthenticate, asyncMiddleware(listVideoThreadComments) ) @@ -69,10 +71,12 @@ export { async function listVideoThreads (req: express.Request, res: express.Response, next: express.NextFunction) { const video = res.locals.video as VideoModel + const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined + let resultList: ResultList if (video.commentsEnabled === true) { - resultList = await VideoCommentModel.listThreadsForApi(video.id, req.query.start, req.query.count, req.query.sort) + resultList = await VideoCommentModel.listThreadsForApi(video.id, req.query.start, req.query.count, req.query.sort, user) } else { resultList = { total: 0, @@ -85,10 +89,12 @@ async function listVideoThreads (req: express.Request, res: express.Response, ne async function listVideoThreadComments (req: express.Request, res: express.Response, next: express.NextFunction) { const video = res.locals.video as VideoModel + const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined + let resultList: ResultList if (video.commentsEnabled === true) { - resultList = await VideoCommentModel.listThreadCommentsForApi(video.id, res.locals.videoCommentThread.id) + resultList = await VideoCommentModel.listThreadCommentsForApi(video.id, res.locals.videoCommentThread.id, user) } else { resultList = { total: 0, diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 6a73e13d0..664154406 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -437,7 +437,7 @@ async function listVideos (req: express.Request, res: express.Response, next: ex nsfw: buildNSFWFilter(res, req.query.nsfw), filter: req.query.filter as VideoFilter, withFiles: false, - userId: res.locals.oauth ? res.locals.oauth.token.User.id : undefined + user: res.locals.oauth ? res.locals.oauth.token.User : undefined }) return res.json(getFormattedObjects(resultList.data, resultList.total)) -- cgit v1.2.3