From: Chocobozzz Date: Wed, 21 Mar 2018 10:17:01 +0000 (+0100) Subject: Fix mentions in comments X-Git-Tag: v1.0.0-beta.2~71 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a3cffab42d78560a7db8ad1df14680be5b55277f;p=oweals%2Fpeertube.git Fix mentions in comments --- 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