diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/settings/preferences_controller.rb | 6 | ||||
-rw-r--r-- | app/lib/status_filter.rb | 19 | ||||
-rw-r--r-- | app/lib/user_settings_decorator.rb | 30 | ||||
-rw-r--r-- | app/models/user.rb | 30 | ||||
-rw-r--r-- | app/views/settings/preferences/show.html.haml | 6 |
5 files changed, 87 insertions, 4 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 8cfc1de73..85fc062d5 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -38,6 +38,12 @@ class Settings::PreferencesController < Settings::BaseController :setting_larger_buttons, :setting_larger_drawer, :setting_remove_filtered, + :setting_hide_replies_muted, + :setting_hide_replies_blocked, + :setting_hide_replies_blocker, + :setting_hide_mntions_muted, + :setting_hide_mntions_blocked, + :setting_hide_mntions_blocker, :setting_gently_kobolds, :setting_user_is_kobold, diff --git a/app/lib/status_filter.rb b/app/lib/status_filter.rb index b50057c24..b2e80ec92 100644 --- a/app/lib/status_filter.rb +++ b/app/lib/status_filter.rb @@ -28,7 +28,9 @@ class StatusFilter def filtered_reference? # filter muted/blocked - return true if reply_to_blocked? || reply_to_muted? + return true if account&.user&.setting_hide_replies_blocked? && reply_to_blocked? + return true if account&.user&.setting_hide_replies_muted? && reply_to_muted? + return true if account&.user&.setting_hide_replies_blocker? && reply_to_blocker? # kajiht has no filters if status has no mentions return false if status&.mentions.nil? @@ -40,16 +42,21 @@ class StatusFilter return false if mentioned_account_ids.include?(account.id) # Otherwise, filter the status if it mentions someone you've muted. - return true if @preloaded_relations[:muting] && mentioned_account_ids.any? do |mentioned_account_id| + return true if account&.user&.setting_hide_mntions_muted && @preloaded_relations[:muting] && mentioned_account_ids.any? do |mentioned_account_id| @preloaded_relations[:muting][mentioned_account_id] end return true if account.muting?(mentioned_account_ids) # Same as above, but for blocks: - return true if @preloaded_relations[:blocking] && mentioned_account_ids.any? do |mentioned_account_id| + return true if account&.user&.setting_hide_mntions_blocked && @preloaded_relations[:blocking] && mentioned_account_ids.any? do |mentioned_account_id| @preloaded_relations[:blocking][mentioned_account_id] end - account.blocking?(mentioned_account_ids) + return true if account.blocking?(mentioned_account_ids) + + # Filter statuses that mention someone who's blocking you. + return true if account&.user&.setting_hide_mntions_blocker && status.reply && mentioned_account_ids.any? do |mentioned_account_id| + Account.find(mentioned_account_id)&.blocking?(status.account_id) + end end def reply_to_blocked? @@ -76,6 +83,10 @@ class StatusFilter @preloaded_relations[:following] ? @preloaded_relations[:following][status.account_id] : account&.following?(status.account_id) end + def reply_to_blocker? + status.reply? && status.in_reply_to_account.blocking?(status.account_id) + end + def non_self_reply? status.reply? && status.in_reply_to_account_id != status.account_id end diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index 9d157df4e..650e290da 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -23,6 +23,12 @@ class UserSettingsDecorator user.settings['larger_buttons'] = larger_buttons_preference if change?('setting_larger_buttons') user.settings['larger_drawer'] = larger_drawer_preference if change?('setting_larger_drawer') user.settings['remove_filtered'] = remove_filtered_preference if change?('setting_remove_filtered') + user.settings['hide_replies_muted'] = hide_replies_muted_preference if change?('setting_hide_replies_muted') + user.settings['hide_replies_blocked']= hide_replies_blocked_preference if change?('setting_hide_replies_blocked') + user.settings['hide_replies_blocker']= hide_replies_blocker_preference if change?('setting_hide_replies_blocker') + user.settings['hide_mntions_muted'] = hide_mntions_muted_preference if change?('setting_hide_mntions_muted') + user.settings['hide_mntions_blocked']= hide_mntions_blocked_preference if change?('setting_hide_mntions_blocked') + user.settings['hide_mntions_blocker']= hide_mntions_blocker_preference if change?('setting_hide_mntions_blocker') user.settings['gently_kobolds'] = gently_kobolds_preference if change?('setting_gently_kobolds') user.settings['user_is_kobold'] = user_is_kobold_preference if change?('setting_user_is_kobold') @@ -67,6 +73,30 @@ class UserSettingsDecorator boolean_cast_setting 'setting_remove_filtered' end + def hide_replies_muted_preference + boolean_cast_setting 'setting_hide_replies_muted' + end + + def hide_replies_blocked_preference + boolean_cast_setting 'setting_hide_replies_blocked' + end + + def hide_replies_blocker_preference + boolean_cast_setting 'setting_hide_replies_blocker' + end + + def hide_mntions_muted_preference + boolean_cast_setting 'setting_hide_mntions_muted' + end + + def hide_mntions_blocked_preference + boolean_cast_setting 'setting_hide_mntions_blocked' + end + + def hide_mntions_blocker_preference + boolean_cast_setting 'setting_hide_mntions_blocker' + end + def gently_kobolds_preference boolean_cast_setting 'setting_gently_kobolds' end diff --git a/app/models/user.rb b/app/models/user.rb index bcfc49115..29db2e078 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -112,6 +112,12 @@ class User < ApplicationRecord :larger_buttons, :larger_drawer, :remove_filtered, + :hide_replies_muted, + :hide_replies_blocked, + :hide_replies_blocker, + :hide_mntions_muted, + :hide_mntions_blocked, + :hide_mntions_blocker, :gently_kobolds, :user_is_kobold, @@ -232,6 +238,30 @@ class User < ApplicationRecord settings.remove_filtered || false end + def setting_hide_replies_muted + settings.hide_replies_muted || true + end + + def setting_hide_replies_blocked + settings.hide_replies_blocked || true + end + + def setting_hide_replies_blocker + settings.hide_replies_blocker || true + end + + def setting_hide_mntions_muted + settings.hide_mntions_muted || true + end + + def setting_hide_mntions_blocked + settings.hide_mntions_blocked || true + end + + def setting_hide_mntions_blocker + settings.hide_mntions_blocker || true + end + def setting_gently_kobolds settings.gently_kobolds || false end diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml index bd5e8c532..48d28e17d 100644 --- a/app/views/settings/preferences/show.html.haml +++ b/app/views/settings/preferences/show.html.haml @@ -64,6 +64,12 @@ .fields-group = f.input :setting_remove_filtered, as: :boolean, wrapper: :with_label + = f.input :setting_hide_replies_muted, as: :boolean, wrapper: :with_label + = f.input :setting_hide_replies_blocked, as: :boolean, wrapper: :with_label + = f.input :setting_hide_replies_blocker, as: :boolean, wrapper: :with_label + = f.input :setting_hide_mntions_muted, as: :boolean, wrapper: :with_label + = f.input :setting_hide_mntions_blocked, as: :boolean, wrapper: :with_label + = f.input :setting_hide_mntions_blocker, as: :boolean, wrapper: :with_label .fields-group = f.input :setting_unfollow_modal, as: :boolean, wrapper: :with_label |