diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-19 09:50:13 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-19 10:06:52 +0100 |
commit | 9d6b9d10ef8cbef39e89bc709285abffb0d8caa1 (patch) | |
tree | 3425b22556e00d1b15de15c72b2802cfc9374473 /server/controllers | |
parent | fae6e4da8f516a9d6c3bad9bf6f35811ccacbad8 (diff) | |
download | PeerTube-9d6b9d10ef8cbef39e89bc709285abffb0d8caa1.tar.gz PeerTube-9d6b9d10ef8cbef39e89bc709285abffb0d8caa1.tar.zst PeerTube-9d6b9d10ef8cbef39e89bc709285abffb0d8caa1.zip |
Fix video comments display with deleted comments
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/videos/comment.ts | 13 |
1 files changed, 10 insertions, 3 deletions
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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { ResultList, UserRight } from '../../../../shared/models' | 2 | import { ResultList, ThreadsResultList, UserRight } from '../../../../shared/models' |
3 | import { VideoCommentCreate } from '../../../../shared/models/videos/video-comment.model' | 3 | import { VideoCommentCreate } from '../../../../shared/models/videos/video-comment.model' |
4 | import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' | 4 | import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' |
5 | import { getFormattedObjects } from '../../../helpers/utils' | 5 | import { getFormattedObjects } from '../../../helpers/utils' |
@@ -30,6 +30,7 @@ import { | |||
30 | import { AccountModel } from '../../../models/account/account' | 30 | import { AccountModel } from '../../../models/account/account' |
31 | import { VideoCommentModel } from '../../../models/video/video-comment' | 31 | import { VideoCommentModel } from '../../../models/video/video-comment' |
32 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 32 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
33 | import { logger } from '@server/helpers/logger' | ||
33 | 34 | ||
34 | const auditLogger = auditLoggerFactory('comments') | 35 | const auditLogger = auditLoggerFactory('comments') |
35 | const videoCommentRouter = express.Router() | 36 | const videoCommentRouter = express.Router() |
@@ -108,7 +109,7 @@ async function listVideoThreads (req: express.Request, res: express.Response) { | |||
108 | const video = res.locals.onlyVideo | 109 | const video = res.locals.onlyVideo |
109 | const user = res.locals.oauth ? res.locals.oauth.token.User : undefined | 110 | const user = res.locals.oauth ? res.locals.oauth.token.User : undefined |
110 | 111 | ||
111 | let resultList: ResultList<VideoCommentModel> | 112 | let resultList: ThreadsResultList<VideoCommentModel> |
112 | 113 | ||
113 | if (video.commentsEnabled === true) { | 114 | if (video.commentsEnabled === true) { |
114 | const apiOptions = await Hooks.wrapObject({ | 115 | const apiOptions = await Hooks.wrapObject({ |
@@ -128,11 +129,15 @@ async function listVideoThreads (req: express.Request, res: express.Response) { | |||
128 | } else { | 129 | } else { |
129 | resultList = { | 130 | resultList = { |
130 | total: 0, | 131 | total: 0, |
132 | totalNotDeletedComments: 0, | ||
131 | data: [] | 133 | data: [] |
132 | } | 134 | } |
133 | } | 135 | } |
134 | 136 | ||
135 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | 137 | return res.json({ |
138 | ...getFormattedObjects(resultList.data, resultList.total), | ||
139 | totalNotDeletedComments: resultList.totalNotDeletedComments | ||
140 | }) | ||
136 | } | 141 | } |
137 | 142 | ||
138 | async function listVideoThreadComments (req: express.Request, res: express.Response) { | 143 | async function listVideoThreadComments (req: express.Request, res: express.Response) { |
@@ -161,6 +166,8 @@ async function listVideoThreadComments (req: express.Request, res: express.Respo | |||
161 | } | 166 | } |
162 | } | 167 | } |
163 | 168 | ||
169 | logger.info('coucou', { resultList }) | ||
170 | |||
164 | if (resultList.data.length === 0) { | 171 | if (resultList.data.length === 0) { |
165 | return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 172 | return res.sendStatus(HttpStatusCode.NOT_FOUND_404) |
166 | } | 173 | } |