diff options
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/status_filter.rb | 19 | ||||
-rw-r--r-- | app/lib/user_settings_decorator.rb | 30 |
2 files changed, 45 insertions, 4 deletions
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 |