From 08bf098611caa1a26cdbfdd3e26a0d8d2800a15d Mon Sep 17 00:00:00 2001 From: Marcel Hellkamp Date: Mon, 31 Jul 2023 16:18:27 +0200 Subject: [PATCH] Filter statuses at API level if possible --- src/sources.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sources.ts b/src/sources.ts index fe65d52..c65a6fe 100644 --- a/src/sources.ts +++ b/src/sources.ts @@ -17,9 +17,12 @@ export async function fetchPosts(cfg: Config): Promise { // Load tags from all servers for (const domain of cfg.servers) { + const query: Record = { limit: cfg.limit } + if(cfg.badWords.length) query.none = cfg.badWords.join(",") + if(!cfg.showText) query.only_media = "True" for (const tag of cfg.tags) { addTask(domain, async () => { - return await fetchJson(domain, `api/v1/timelines/tag/${encodeURIComponent(tag)}`, { limit: cfg.limit.toString() }) + return await fetchJson(domain, `api/v1/timelines/tag/${encodeURIComponent(tag)}`, query) }) } } @@ -38,6 +41,7 @@ export async function fetchPosts(cfg: Config): Promise { const query: Record = { limit: cfg.limit } if (cfg.hideReplies) query.exclude_replies = "True" if (cfg.hideBoosts) query.exclude_reblogs = "True" + if (!cfg.showText) query.only_media = "True" return await fetchJson(domain, `api/v1/accounts/${encodeURIComponent(localUser.id)}/statuses`, query) }) } @@ -59,6 +63,7 @@ export async function fetchPosts(cfg: Config): Promise { const query: Record = { limit: cfg.limit } if (!cfg.loadPublic) query.remote = "True" if (!cfg.loadFederated) query.local = "True" + if (!cfg.showText) query.only_media = "True" addTask(domain, async () => { return await fetchJson(domain, "api/v1/timelines/public", query) })