From f4677e45f4928c8f81647df0fa392febdbe258f6 Mon Sep 17 00:00:00 2001 From: Bastard Operator Date: Thu, 31 Dec 2020 01:22:13 +0100 Subject: [PATCH] Filter #fedilove on federated timeline and direct messages to-do: think about leaving this client side? Is there a way to filter federated toots on Mastodon by searching a name containing X string? --- src/routes/_api/timelines.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/routes/_api/timelines.js b/src/routes/_api/timelines.js index 2da8aa28..510f43db 100644 --- a/src/routes/_api/timelines.js +++ b/src/routes/_api/timelines.js @@ -90,5 +90,20 @@ export async function getTimeline (instanceName, accessToken, timeline, maxId, s if (timeline === 'direct') { items = items.map(item => item.last_status) } + + if (timeline === 'direct' || timeline === 'federated') { + let newItems = []; + for (var item of items) { + if (item.account === undefined) + continue; + if (item.account.display_name.toLowerCase().includes('#fedilove')) { + item.account.display_name = + item.account.display_name.replace(/#fedilove/gi, '').trim(); + newItems.push(item); + } + } + items = newItems; + } + return { items, headers } }