diff --git a/packages/backend/src/core/QueryService.ts b/packages/backend/src/core/QueryService.ts index c4feeaf9717e7ddd56e7e64a36130c1b2e35ca5d..1fbc9c44063bbcf03fc628c903e952a92c39c011 100644 --- a/packages/backend/src/core/QueryService.ts +++ b/packages/backend/src/core/QueryService.ts @@ -88,6 +88,12 @@ export class QueryService { qb .where('note.renoteUserId IS NULL') .orWhere(`note.renoteUserId NOT IN (${ blockingQuery.getQuery() })`); + })) + // filter out renotes where the user being replied to is muted. + .andWhere(new Brackets(qb => { + qb + .where('(SELECT "replyUserId" FROM note n WHERE "n".id = note.renoteId) IS NULL') + .orWhere(`(SELECT "replyUserId" FROM note n WHERE "n".id = note.renoteId) NOT IN (${ blockingQuery.getQuery() })`); })); q.setParameters(blockingQuery.getParameters()); @@ -155,6 +161,12 @@ export class QueryService { .where('note.renoteUserId IS NULL') .orWhere(`note.renoteUserId NOT IN (${ mutingQuery.getQuery() })`); })) + // filter out renotes where the user being replied to is muted. + .andWhere(new Brackets(qb => { + qb + .where('(SELECT "replyUserId" FROM note n WHERE "n".id = note.renoteId) IS NULL') + .orWhere(`(SELECT "replyUserId" FROM note n WHERE "n".id = note.renoteId) NOT IN (${ mutingQuery.getQuery() })`); + })) // mute instances .andWhere(new Brackets(qb => { qb diff --git a/packages/backend/src/misc/is-user-related.ts b/packages/backend/src/misc/is-user-related.ts index 862d6e6a3839be434535c49dec2668c6154a43ce..f44765988d4e647bb5ad90293bece7ce9e3d87d6 100644 --- a/packages/backend/src/misc/is-user-related.ts +++ b/packages/backend/src/misc/is-user-related.ts @@ -20,5 +20,9 @@ export function isUserRelated(note: any, userIds: Set<string>, ignoreAuthor = fa return true; } + if (note.renote?.replyUserId != null && note.renote?.replyUserId !== note.userId && userIds.has(note.renote?.replyUserId)) { + return true; + } + return false; }