aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/comment.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos/comment.ts')
-rw-r--r--server/controllers/api/videos/comment.ts12
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
8import { 8import {
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)
41videoCommentRouter.get('/:videoId/comment-threads/:threadId', 42videoCommentRouter.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
70async function listVideoThreads (req: express.Request, res: express.Response, next: express.NextFunction) { 72async 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
86async function listVideoThreadComments (req: express.Request, res: express.Response, next: express.NextFunction) { 90async 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,