merge: Hide renotes where the user being replied to is muted. (!794)

View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/794
This commit is contained in:
piuvas silly 2024-12-02 10:30:53 +00:00
commit 4a52805b30
2 changed files with 16 additions and 0 deletions

View file

@ -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

View file

@ -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;
}