diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-12-21 13:59:38 -0600 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-12-21 13:59:38 -0600 |
commit | 5f92c6429fac98e5c9e3b02d158b6d4eab89945d (patch) | |
tree | 7ffa8f2d41288c88ba8720a42d747924fa371e10 /app | |
parent | 8312a6e51017498c417070cbcbf115da184b786d (diff) |
add option to only apply phrase filters to timelines
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/settings/preferences_controller.rb | 1 | ||||
-rw-r--r-- | app/lib/status_filter.rb | 8 | ||||
-rw-r--r-- | app/models/user.rb | 1 | ||||
-rw-r--r-- | app/views/settings/preferences/show.html.haml | 3 |
4 files changed, 9 insertions, 4 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 4ac654590..2ff84ac80 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -32,6 +32,7 @@ class Settings::PreferencesController < Settings::BaseController :hide_boosts, :only_known, :invert_filters, + :filter_timelines_only, chosen_languages: [] ) end diff --git a/app/lib/status_filter.rb b/app/lib/status_filter.rb index fb675cbbd..4cb5804da 100644 --- a/app/lib/status_filter.rb +++ b/app/lib/status_filter.rb @@ -15,9 +15,9 @@ class StatusFilter def filtered? return true if status.nil? || account.nil? return false if !account.nil? && account.id == status.account_id - return !account.user.invert_filters if redis.sismember("filtered_statuses:#{account.id}", status.id) + return !account.user.invert_filters if !account.user.filter_timelines_only && redis.sismember("filtered_statuses:#{account.id}", status.id) if blocked_by_policy? || (account_present? && filtered_status?) || silenced_account? - redis.sadd("filtered_statuses:#{account.id}", status.id) + redis.sadd("filtered_statuses:#{account.id}", status.id) unless account.user.filter_timelines_only return true end false @@ -40,7 +40,7 @@ class StatusFilter return true if account.user_hides_replies_of_blocker? && reply_to_blocker? # filtered by user? - return true if !account.user.invert_filters && phrase_filtered?(status, account.id) + return true if !account.user.filter_timelines_only && !account.user.invert_filters && phrase_filtered?(status, account.id) # kajiht has no filters if status has no mentions return false if status&.mentions.blank? @@ -77,7 +77,7 @@ class StatusFilter return true if !@preloaded_relations[:following] && (mentioned_account_ids - account.following_ids).any? # filtered by user? - account.user.invert_filters && !phrase_filtered?(status, account.id) + !account.user.filter_timelines_only && account.user.invert_filters && !phrase_filtered?(status, account.id) end def reply_to_blocked? diff --git a/app/models/user.rb b/app/models/user.rb index f6e1a369d..2ee304e81 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -42,6 +42,7 @@ # hide_boosts :boolean # only_known :boolean # invert_filters :boolean default(FALSE), not null +# filter_timelines_only :boolean default(FALSE), not null # class User < ApplicationRecord diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml index 8f4563fde..80ad6c109 100644 --- a/app/views/settings/preferences/show.html.haml +++ b/app/views/settings/preferences/show.html.haml @@ -47,6 +47,9 @@ .fields-group = f.input :invert_filters, as: :boolean, wrapper: :with_label + = f.input :filter_timelines_only, as: :boolean, wrapper: :with_label + + .fields-group = f.input :setting_rawr_federated, as: :boolean, wrapper: :with_label = f.input :hide_boosts, as: :boolean, wrapper: :with_label = f.input :only_known, as: :boolean, wrapper: :with_label |