import * as express from 'express'
-import { ResultList, UserRight } from '../../../../shared/models'
+import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { ResultList, ThreadsResultList, UserRight } from '../../../../shared/models'
import { VideoCommentCreate } from '../../../../shared/models/videos/video-comment.model'
import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
import { getFormattedObjects } from '../../../helpers/utils'
const video = res.locals.onlyVideo
const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
- let resultList: ResultList<VideoCommentModel>
+ let resultList: ThreadsResultList<VideoCommentModel>
if (video.commentsEnabled === true) {
const apiOptions = await Hooks.wrapObject({
} else {
resultList = {
total: 0,
+ totalNotDeletedComments: 0,
data: []
}
}
- return res.json(getFormattedObjects(resultList.data, resultList.total))
+ return res.json({
+ ...getFormattedObjects(resultList.data, resultList.total),
+ totalNotDeletedComments: resultList.totalNotDeletedComments
+ })
}
async function listVideoThreadComments (req: express.Request, res: express.Response) {
}
if (resultList.data.length === 0) {
- return res.sendStatus(404)
+ return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
}
return res.json(buildFormattedCommentTree(resultList))
auditLogger.delete(getAuditIdFromRes(res), new CommentAuditView(videoCommentInstance.toFormattedJSON()))
- return res.type('json').status(204).end()
+ return res.type('json')
+ .status(HttpStatusCode.NO_CONTENT_204)
+ .end()
}