aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-19 09:50:13 +0100
committerChocobozzz <me@florianbigard.com>2021-02-19 10:06:52 +0100
commit9d6b9d10ef8cbef39e89bc709285abffb0d8caa1 (patch)
tree3425b22556e00d1b15de15c72b2802cfc9374473 /server/controllers
parentfae6e4da8f516a9d6c3bad9bf6f35811ccacbad8 (diff)
downloadPeerTube-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.ts13
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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { ResultList, UserRight } from '../../../../shared/models' 2import { ResultList, ThreadsResultList, 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'
@@ -30,6 +30,7 @@ import {
30import { AccountModel } from '../../../models/account/account' 30import { AccountModel } from '../../../models/account/account'
31import { VideoCommentModel } from '../../../models/video/video-comment' 31import { VideoCommentModel } from '../../../models/video/video-comment'
32import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 32import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
33import { logger } from '@server/helpers/logger'
33 34
34const auditLogger = auditLoggerFactory('comments') 35const auditLogger = auditLoggerFactory('comments')
35const videoCommentRouter = express.Router() 36const 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
138async function listVideoThreadComments (req: express.Request, res: express.Response) { 143async 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 }