fix(backend): ブロックホストがない場合はINクエリを生成しない。 (#10258)

空のINクエリはシンタックスエラーとなるため。
This commit is contained in:
danominium 2023-03-07 20:09:20 +09:00 committed by GitHub
parent b20703c185
commit 4f0bb70118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -76,9 +76,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (typeof ps.blocked === 'boolean') { if (typeof ps.blocked === 'boolean') {
const meta = await this.metaService.fetch(true); const meta = await this.metaService.fetch(true);
if (ps.blocked) { if (ps.blocked) {
query.andWhere('instance.host IN (:...blocks)', { blocks: meta.blockedHosts }); query.andWhere(meta.blockedHosts.length === 0 ? '1=0': 'instance.host IN (:...blocks)', { blocks: meta.blockedHosts });
} else { } else {
query.andWhere('instance.host NOT IN (:...blocks)', { blocks: meta.blockedHosts }); query.andWhere(meta.blockedHosts.length === 0 ? '1=1': 'instance.host NOT IN (:...blocks)', { blocks: meta.blockedHosts });
} }
} }