Fix search-by-tag

This commit is contained in:
mei23 2021-05-23 12:53:00 +09:00
parent e6754eb880
commit c971d1d5d8
No known key found for this signature in database
GPG Key ID: DD8628500D3E4B23
1 changed files with 2 additions and 6 deletions

View File

@ -105,17 +105,13 @@ export default define(meta, async (ps, me) => {
if (me) generateMutedUserQuery(query, me); if (me) generateMutedUserQuery(query, me);
if (ps.tag) { if (ps.tag) {
if (!safeForSql(ps.tag)) return; query.andWhere(`'{"${safeForSql(ps.tag) ? normalizeForSearch(ps.tag) : 'aichan_kawaii'}"}' <@ note.tags`);
query.andWhere(`'{"${normalizeForSearch(ps.tag)}"}' <@ note.tags`);
} else { } else {
let i = 0;
query.andWhere(new Brackets(qb => { query.andWhere(new Brackets(qb => {
for (const tags of ps.query!) { for (const tags of ps.query!) {
qb.orWhere(new Brackets(qb => { qb.orWhere(new Brackets(qb => {
for (const tag of tags) { for (const tag of tags) {
if (!safeForSql(tag)) return; qb.andWhere(`'{"${safeForSql(tag) ? normalizeForSearch(tag) : 'aichan_kawaii'}"}' <@ note.tags`);
qb.andWhere(`'{"${normalizeForSearch(ps.tag)}"}' <@ note.tags`);
i++;
} }
})); }));
} }