X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-comment.ts;h=5386a10aa4892a8fa9f9b58f6150da30c1c0b31d;hb=48dce1c90dff4e90a4bcffefaecf157336cf904b;hp=bf8da924d5555ee5d06911941100f5ee47881c7d;hpb=09cababd79f9d445aa027c93cdfe823745fa041a;p=github%2FChocobozzz%2FPeerTube.git 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