From 2a021e6cb6836864bb013d5ff451e8a4ae45c9b7 Mon Sep 17 00:00:00 2001
From: Chocobozzz <me@florianbigard.com>
Date: Fri, 19 Feb 2021 10:52:31 +0100
Subject: [PATCH] Fix thread replies API response

---
 server/controllers/api/videos/comment.ts |  2 --
 server/models/video/video-comment.ts     | 28 ++++++++++++++----------
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts
index b21698525..38fa7c3b0 100644
--- a/server/controllers/api/videos/comment.ts
+++ b/server/controllers/api/videos/comment.ts
@@ -166,8 +166,6 @@ 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)
   }
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts
index cfd1d5b7a..dc7556d44 100644
--- a/server/models/video/video-comment.ts
+++ b/server/models/video/video-comment.ts
@@ -483,20 +483,26 @@ export class VideoCommentModel extends Model {
       order: [ [ 'createdAt', 'ASC' ], [ 'updatedAt', 'ASC' ] ] as Order,
       where: {
         videoId,
-        [Op.or]: [
-          { id: threadId },
-          { originCommentId: threadId }
-        ],
-        [Op.or]: [
+        [Op.and]: [
           {
-            accountId: {
-              [Op.notIn]: Sequelize.literal(
-                '(' + buildBlockedAccountSQL(blockerAccountIds) + ')'
-              )
-            }
+            [Op.or]: [
+              { id: threadId },
+              { originCommentId: threadId }
+            ]
           },
           {
-            accountId: null
+            [Op.or]: [
+              {
+                accountId: {
+                  [Op.notIn]: Sequelize.literal(
+                    '(' + buildBlockedAccountSQL(blockerAccountIds) + ')'
+                  )
+                }
+              },
+              {
+                accountId: null
+              }
+            ]
           }
         ]
       }