From a3cffab42d78560a7db8ad1df14680be5b55277f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 21 Mar 2018 11:17:01 +0100 Subject: Fix mentions in comments --- server/models/video/video-comment.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'server') diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index bf8da924d..5386a10aa 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts @@ -307,15 +307,15 @@ export class VideoCommentModel extends Model { const query = { order: [ [ 'createdAt', order ] ], where: { - [ Sequelize.Op.or ]: [ - { id: comment.getThreadId() }, - { originCommentId: comment.getThreadId() } - ], id: { + [ Sequelize.Op.in ]: Sequelize.literal('(' + + 'WITH RECURSIVE children (id, "inReplyToCommentId") AS ( ' + + 'SELECT id, "inReplyToCommentId" FROM "videoComment" WHERE id = ' + comment.id + ' UNION ' + + 'SELECT p.id, p."inReplyToCommentId" from "videoComment" p ' + + 'INNER JOIN children c ON c."inReplyToCommentId" = p.id) ' + + 'SELECT id FROM children' + + ')'), [ Sequelize.Op.ne ]: comment.id - }, - createdAt: { - [ Sequelize.Op.lt ]: comment.createdAt } }, transaction: t -- cgit v1.2.3