From 9d6b9d10ef8cbef39e89bc709285abffb0d8caa1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 Feb 2021 09:50:13 +0100 Subject: Fix video comments display with deleted comments --- server/controllers/api/videos/comment.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index 752a33596..b21698525 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts @@ -1,5 +1,5 @@ import * as express from 'express' -import { ResultList, UserRight } from '../../../../shared/models' +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' @@ -30,6 +30,7 @@ import { import { AccountModel } from '../../../models/account/account' import { VideoCommentModel } from '../../../models/video/video-comment' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { logger } from '@server/helpers/logger' const auditLogger = auditLoggerFactory('comments') const videoCommentRouter = express.Router() @@ -108,7 +109,7 @@ async function listVideoThreads (req: express.Request, res: express.Response) { const video = res.locals.onlyVideo const user = res.locals.oauth ? res.locals.oauth.token.User : undefined - let resultList: ResultList + let resultList: ThreadsResultList if (video.commentsEnabled === true) { const apiOptions = await Hooks.wrapObject({ @@ -128,11 +129,15 @@ async function listVideoThreads (req: express.Request, res: express.Response) { } 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) { @@ -161,6 +166,8 @@ async function listVideoThreadComments (req: express.Request, res: express.Respo } } + logger.info('coucou', { resultList }) + if (resultList.data.length === 0) { return res.sendStatus(HttpStatusCode.NOT_FOUND_404) } -- cgit v1.2.3