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?
This commit is contained in:
Bofh 2020-12-31 01:22:13 +01:00
parent 3d0eaaea66
commit f4677e45f4
1 changed files with 15 additions and 0 deletions

View File

@ -90,5 +90,20 @@ export async function getTimeline (instanceName, accessToken, timeline, maxId, s
if (timeline === 'direct') { if (timeline === 'direct') {
items = items.map(item => item.last_status) 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 } return { items, headers }
} }