mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-21 19:53:50 +01:00
[backend] Improve postgres FTS attachment filter query
This commit is contained in:
parent
1b4fedc59f
commit
292e537dc7
@ -178,11 +178,13 @@ function attachmentFilter(query: SelectQueryBuilder<any>, filter: string) {
|
||||
case 'image':
|
||||
case 'video':
|
||||
case 'audio':
|
||||
query.andWhere(`note.attachedFileTypes && array[:...types]::varchar[]`, { types: FILE_TYPE_BROWSERSAFE.filter(t => t.startsWith(`${filter}/`)) });
|
||||
query.andWhere(`note."attachedFileTypes"::varchar ILIKE :type`, { type: `%${sqlLikeEscape(filter)}/%` });
|
||||
break;
|
||||
case 'file':
|
||||
query.andWhere(`note.attachedFileTypes <> '{}'`);
|
||||
query.andWhere(`NOT (note.attachedFileTypes && array[:...types]::varchar[])`, { types: FILE_TYPE_BROWSERSAFE });
|
||||
query.andWhere(`note."attachedFileTypes" <> '{}'`);
|
||||
query.andWhere(`NOT (note."attachedFileTypes"::varchar ILIKE '%image/%')`);
|
||||
query.andWhere(`NOT (note."attachedFileTypes"::varchar ILIKE '%video/%')`);
|
||||
query.andWhere(`NOT (note."attachedFileTypes"::varchar ILIKE '%audio/%')`);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user