Add the picked providers and a Must include group

This commit is contained in:
Fisto
2026-09-17 11:28:27 +02:00
parent 83dd9bc0fa
commit c6caa168be
11 changed files with 229 additions and 119 deletions
+15
View File
@@ -119,6 +119,10 @@ export interface MediaFilterOptions {
excludeProviders?: string[];
/** Row sources to hide (attachment, sticker, embed). */
excludeSources?: string[];
/** Keep only providers matching one of these substrings; empty keeps all. */
includeProviders?: string[];
/** Keep only these row sources; empty keeps all. */
includeSources?: string[];
/** Bytes; rows with no known size drop out while this is set. */
sizeLessThan?: number;
sizeGreaterThan?: number;
@@ -609,6 +613,17 @@ export class ScrapeStore {
conditions.push(`COALESCE(source, '') NOT IN (${options.excludeSources.map(() => "?").join(", ")})`);
values.push(...options.excludeSources);
}
if (options.includeProviders?.length) {
const clauses = options.includeProviders.map(() => "lower(COALESCE(provider, '')) LIKE ?");
conditions.push(`(${clauses.join(" OR ")})`);
for (const provider of options.includeProviders) {
values.push(`%${provider.toLowerCase()}%`);
}
}
if (options.includeSources?.length) {
conditions.push(`COALESCE(source, '') IN (${options.includeSources.map(() => "?").join(", ")})`);
values.push(...options.includeSources);
}
if (options.sizeLessThan !== undefined) {
conditions.push("COALESCE(file_bytes, size) < ?");
values.push(options.sizeLessThan);