-import * as express from 'express'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
-import { ResultList, ThreadsResultList, UserRight } from '../../../../shared/models'
-import { VideoCommentCreate } from '../../../../shared/models/videos/comment/video-comment.model'
+import express from 'express'
+import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
+import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model'
import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
import { getFormattedObjects } from '../../../helpers/utils'
import { sequelizeTypescript } from '../../../initializers/database'
return res.json({
...getFormattedObjects(resultList.data, resultList.total),
totalNotDeletedComments: resultList.totalNotDeletedComments
- })
+ } as VideoCommentThreads)
}
async function listVideoThreadComments (req: express.Request, res: express.Response) {
}
if (resultList.data.length === 0) {
- return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
+ return res.fail({
+ status: HttpStatusCode.NOT_FOUND_404,
+ message: 'No comments were found'
+ })
}
return res.json(buildFormattedCommentTree(resultList))
Notifier.Instance.notifyOnNewComment(comment)
auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON()))
- Hooks.runAction('action:api.video-thread.created', { comment })
+ Hooks.runAction('action:api.video-thread.created', { comment, req, res })
return res.json({ comment: comment.toFormattedJSON() })
}
Notifier.Instance.notifyOnNewComment(comment)
auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON()))
- Hooks.runAction('action:api.video-comment-reply.created', { comment })
+ Hooks.runAction('action:api.video-comment-reply.created', { comment, req, res })
return res.json({ comment: comment.toFormattedJSON() })
}
async function removeVideoComment (req: express.Request, res: express.Response) {
const videoCommentInstance = res.locals.videoCommentFull
- await removeComment(videoCommentInstance)
+ await removeComment(videoCommentInstance, req, res)
auditLogger.delete(getAuditIdFromRes(res), new CommentAuditView(videoCommentInstance.toFormattedJSON()))