make QueryService.generateSuspendedUserQueryForNote automatically add all required joins

This commit is contained in:
Hazelnoot 2025-08-13 11:54:44 -04:00
parent f1fc8bc357
commit 96ee635765

View file

@ -663,9 +663,14 @@ export class QueryService {
return q[join](`NOT EXISTS (${threadMutedQuery.getQuery()})`, threadMutedQuery.getParameters());
}
// Requirements: user replyUser renoteUser must be joined
@bindThis
public generateSuspendedUserQueryForNote(q: SelectQueryBuilder<any>, excludeAuthor?: boolean): void {
public generateSuspendedUserQueryForNote<E extends ObjectLiteral>(q: SelectQueryBuilder<E>, excludeAuthor?: boolean): void {
this.leftJoin(q, 'note.user', 'user');
this.leftJoin(q, 'note.reply', 'reply');
this.leftJoin(q, 'note.renote', 'renote');
this.leftJoin(q, 'reply.user', 'replyUser');
this.leftJoin(q, 'renote.user', 'renoteUser');
if (excludeAuthor) {
const brakets = (user: string) => new Brackets(qb => qb
.where(`note.${user}Id IS NULL`)