aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/videos/comment.ts36
1 files changed, 35 insertions, 1 deletions
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts
index 45ff969d9..ccd76c093 100644
--- a/server/controllers/api/videos/comment.ts
+++ b/server/controllers/api/videos/comment.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { ResultList } from '../../../../shared/models' 2import { ResultList, UserRight } from '../../../../shared/models'
3import { VideoCommentCreate } from '../../../../shared/models/videos/video-comment.model' 3import { VideoCommentCreate } from '../../../../shared/models/videos/video-comment.model'
4import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' 4import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
5import { getFormattedObjects } from '../../../helpers/utils' 5import { getFormattedObjects } from '../../../helpers/utils'
@@ -11,6 +11,7 @@ import {
11 asyncMiddleware, 11 asyncMiddleware,
12 asyncRetryTransactionMiddleware, 12 asyncRetryTransactionMiddleware,
13 authenticate, 13 authenticate,
14 ensureUserHasRight,
14 optionalAuthenticate, 15 optionalAuthenticate,
15 paginationValidator, 16 paginationValidator,
16 setDefaultPagination, 17 setDefaultPagination,
@@ -19,9 +20,11 @@ import {
19import { 20import {
20 addVideoCommentReplyValidator, 21 addVideoCommentReplyValidator,
21 addVideoCommentThreadValidator, 22 addVideoCommentThreadValidator,
23 listVideoCommentsValidator,
22 listVideoCommentThreadsValidator, 24 listVideoCommentThreadsValidator,
23 listVideoThreadCommentsValidator, 25 listVideoThreadCommentsValidator,
24 removeVideoCommentValidator, 26 removeVideoCommentValidator,
27 videoCommentsValidator,
25 videoCommentThreadsSortValidator 28 videoCommentThreadsSortValidator
26} from '../../../middlewares/validators' 29} from '../../../middlewares/validators'
27import { AccountModel } from '../../../models/account/account' 30import { AccountModel } from '../../../models/account/account'
@@ -61,6 +64,17 @@ videoCommentRouter.delete('/:videoId/comments/:commentId',
61 asyncRetryTransactionMiddleware(removeVideoComment) 64 asyncRetryTransactionMiddleware(removeVideoComment)
62) 65)
63 66
67videoCommentRouter.get('/comments',
68 authenticate,
69 ensureUserHasRight(UserRight.SEE_ALL_COMMENTS),
70 paginationValidator,
71 videoCommentsValidator,
72 setDefaultSort,
73 setDefaultPagination,
74 listVideoCommentsValidator,
75 asyncMiddleware(listComments)
76)
77
64// --------------------------------------------------------------------------- 78// ---------------------------------------------------------------------------
65 79
66export { 80export {
@@ -69,6 +83,26 @@ export {
69 83
70// --------------------------------------------------------------------------- 84// ---------------------------------------------------------------------------
71 85
86async function listComments (req: express.Request, res: express.Response) {
87 const options = {
88 start: req.query.start,
89 count: req.query.count,
90 sort: req.query.sort,
91
92 isLocal: req.query.isLocal,
93 search: req.query.search,
94 searchAccount: req.query.searchAccount,
95 searchVideo: req.query.searchVideo
96 }
97
98 const resultList = await VideoCommentModel.listCommentsForApi(options)
99
100 return res.json({
101 total: resultList.total,
102 data: resultList.data.map(c => c.toFormattedAdminJSON())
103 })
104}
105
72async function listVideoThreads (req: express.Request, res: express.Response) { 106async function listVideoThreads (req: express.Request, res: express.Response) {
73 const video = res.locals.onlyVideo 107 const video = res.locals.onlyVideo
74 const user = res.locals.oauth ? res.locals.oauth.token.User : undefined 108 const user = res.locals.oauth ? res.locals.oauth.token.User : undefined