Skip to content

Commit

Permalink
Completely hide toots matched by “irreversible” filters even if they …
Browse files Browse the repository at this point in the history
…got to the client (mastodon#11113)

Fixes mastodon#11090
  • Loading branch information
ClearlyClaire authored and Gargron committed Jun 18, 2019
1 parent c16a58d commit 6a0e390
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/javascript/mastodon/actions/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,14 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
let filtered = false;

if (notification.type === 'mention') {
const dropRegex = regexFromFilters(filters.filter(filter => filter.get('irreversible')));
const regex = regexFromFilters(filters);
const searchIndex = notification.status.spoiler_text + '\n' + unescapeHTML(notification.status.content);

if (dropRegex && dropRegex.test(searchIndex)) {
return;
}

filtered = regex && regex.test(searchIndex);
}

Expand Down
9 changes: 7 additions & 2 deletions app/javascript/mastodon/selectors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,13 @@ export const makeGetStatus = () => {
statusReblog = null;
}

const regex = (accountReblog || accountBase).get('id') !== me && regexFromFilters(filters);
const filtered = regex && regex.test(statusBase.get('reblog') ? statusReblog.get('search_index') : statusBase.get('search_index'));
const dropRegex = (accountReblog || accountBase).get('id') !== me && regexFromFilters(filters.filter(filter => filter.get('irreversible')));
if (dropRegex && dropRegex.test(statusBase.get('reblog') ? statusReblog.get('search_index') : statusBase.get('search_index'))) {
return null;
}

const regex = (accountReblog || accountBase).get('id') !== me && regexFromFilters(filters);
const filtered = regex && regex.test(statusBase.get('reblog') ? statusReblog.get('search_index') : statusBase.get('search_index'));

return statusBase.withMutations(map => {
map.set('reblog', statusReblog);
Expand Down

0 comments on commit 6a0e390

Please sign in to comment.