replace generateBlockedHostQueryForNote allowSilenced parameter with generateSilencedUserQueryForNotes

This commit is contained in:
Hazelnoot 2025-06-02 22:56:35 -04:00
parent 0b9c0a6bc7
commit 7ab5ce1537
2 changed files with 5 additions and 15 deletions

View file

@ -190,9 +190,8 @@ export class QueryService {
.setParameters({ meId: me.id });
}
// TODO replace allowSilenced with matchingHostQuery
@bindThis
public generateBlockedHostQueryForNote<E extends ObjectLiteral>(q: SelectQueryBuilder<E>, excludeAuthor?: boolean, allowSilenced = true): SelectQueryBuilder<E> {
public generateBlockedHostQueryForNote<E extends ObjectLiteral>(q: SelectQueryBuilder<E>, excludeAuthor?: boolean): SelectQueryBuilder<E> {
const checkFor = (key: 'user' | 'replyUser' | 'renoteUser') => {
q.andWhere(new Brackets(qb => {
qb.orWhere(`note.${key}Host IS NULL`); // local
@ -207,18 +206,8 @@ export class QueryService {
}
}
if (allowSilenced) {
// not blocked
this.excludeInstanceWhere(qb, `note.${key}Host`, {
isBlocked: false,
}, 'orWhere');
} else {
// not blocked or silenced
this.excludeInstanceWhere(qb, `note.${key}Host`, {
isBlocked: false,
isSilenced: false,
}, 'orWhere');
}
this.excludeInstanceWhere(qb, `note.${key}Host`, { isBlocked: false }, 'orWhere');
}));
};

View file

@ -96,7 +96,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (!this.serverSettings.enableBotTrending) query.andWhere('user.isBot = FALSE');
this.queryService.generateBlockedHostQueryForNote(query, undefined, false);
this.queryService.generateBlockedHostQueryForNote(query);
this.queryService.generateSilencedUserQueryForNotes(query, me);
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
if (me) this.queryService.generateMutedUserRenotesQueryForNotes(query, me);