diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-12 15:26:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-16 16:41:36 +0200 |
commit | 7ad9b9846c44d198a736183fb186c2039f5236b5 (patch) | |
tree | 9c8456882a261c0522efb507f20e323c2741a0f8 /server/controllers/api/videos/comment.ts | |
parent | dffd5d127f49eb63d2b2b3133aec75ec1d7e4dcb (diff) | |
download | PeerTube-7ad9b9846c44d198a736183fb186c2039f5236b5.tar.gz PeerTube-7ad9b9846c44d198a736183fb186c2039f5236b5.tar.zst PeerTube-7ad9b9846c44d198a736183fb186c2039f5236b5.zip |
Add ability for users to block an account/instance on server side
Diffstat (limited to 'server/controllers/api/videos/comment.ts')
-rw-r--r-- | server/controllers/api/videos/comment.ts | 12 |
1 files changed, 9 insertions, 3 deletions
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 | |||
8 | import { | 8 | import { |
9 | asyncMiddleware, | 9 | asyncMiddleware, |
10 | asyncRetryTransactionMiddleware, | 10 | asyncRetryTransactionMiddleware, |
11 | authenticate, | 11 | authenticate, optionalAuthenticate, |
12 | paginationValidator, | 12 | paginationValidator, |
13 | setDefaultPagination, | 13 | setDefaultPagination, |
14 | setDefaultSort | 14 | setDefaultSort |
@@ -36,10 +36,12 @@ videoCommentRouter.get('/:videoId/comment-threads', | |||
36 | setDefaultSort, | 36 | setDefaultSort, |
37 | setDefaultPagination, | 37 | setDefaultPagination, |
38 | asyncMiddleware(listVideoCommentThreadsValidator), | 38 | asyncMiddleware(listVideoCommentThreadsValidator), |
39 | optionalAuthenticate, | ||
39 | asyncMiddleware(listVideoThreads) | 40 | asyncMiddleware(listVideoThreads) |
40 | ) | 41 | ) |
41 | videoCommentRouter.get('/:videoId/comment-threads/:threadId', | 42 | videoCommentRouter.get('/:videoId/comment-threads/:threadId', |
42 | asyncMiddleware(listVideoThreadCommentsValidator), | 43 | asyncMiddleware(listVideoThreadCommentsValidator), |
44 | optionalAuthenticate, | ||
43 | asyncMiddleware(listVideoThreadComments) | 45 | asyncMiddleware(listVideoThreadComments) |
44 | ) | 46 | ) |
45 | 47 | ||
@@ -69,10 +71,12 @@ export { | |||
69 | 71 | ||
70 | async function listVideoThreads (req: express.Request, res: express.Response, next: express.NextFunction) { | 72 | async function listVideoThreads (req: express.Request, res: express.Response, next: express.NextFunction) { |
71 | const video = res.locals.video as VideoModel | 73 | const video = res.locals.video as VideoModel |
74 | const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined | ||
75 | |||
72 | let resultList: ResultList<VideoCommentModel> | 76 | let resultList: ResultList<VideoCommentModel> |
73 | 77 | ||
74 | if (video.commentsEnabled === true) { | 78 | if (video.commentsEnabled === true) { |
75 | resultList = await VideoCommentModel.listThreadsForApi(video.id, req.query.start, req.query.count, req.query.sort) | 79 | resultList = await VideoCommentModel.listThreadsForApi(video.id, req.query.start, req.query.count, req.query.sort, user) |
76 | } else { | 80 | } else { |
77 | resultList = { | 81 | resultList = { |
78 | total: 0, | 82 | total: 0, |
@@ -85,10 +89,12 @@ async function listVideoThreads (req: express.Request, res: express.Response, ne | |||
85 | 89 | ||
86 | async function listVideoThreadComments (req: express.Request, res: express.Response, next: express.NextFunction) { | 90 | async function listVideoThreadComments (req: express.Request, res: express.Response, next: express.NextFunction) { |
87 | const video = res.locals.video as VideoModel | 91 | const video = res.locals.video as VideoModel |
92 | const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined | ||
93 | |||
88 | let resultList: ResultList<VideoCommentModel> | 94 | let resultList: ResultList<VideoCommentModel> |
89 | 95 | ||
90 | if (video.commentsEnabled === true) { | 96 | if (video.commentsEnabled === true) { |
91 | resultList = await VideoCommentModel.listThreadCommentsForApi(video.id, res.locals.videoCommentThread.id) | 97 | resultList = await VideoCommentModel.listThreadCommentsForApi(video.id, res.locals.videoCommentThread.id, user) |
92 | } else { | 98 | } else { |
93 | resultList = { | 99 | resultList = { |
94 | total: 0, | 100 | total: 0, |