diff options
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/status_filter.rb | 29 | ||||
-rw-r--r-- | app/lib/user_settings_decorator.rb | 5 |
2 files changed, 19 insertions, 15 deletions
diff --git a/app/lib/status_filter.rb b/app/lib/status_filter.rb index 8ba8fde2f..4588796dc 100644 --- a/app/lib/status_filter.rb +++ b/app/lib/status_filter.rb @@ -33,7 +33,7 @@ class StatusFilter 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? + return false if status&.mentions.blank? # Grab a list of account IDs mentioned in the status. mentioned_account_ids = status.mentions.pluck(:account_id) @@ -41,22 +41,21 @@ class StatusFilter # Don't filter statuses mentioning you. return false if mentioned_account_ids.include?(account.id) - # Otherwise, filter the status if it mentions someone you've muted. - 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] + return true if mentioned_account_ids.any? do |mentioned_account_id| + should_filter = account&.user&.setting_hide_mntions_muted && @preloaded_relations[:muting] && @preloaded_relations[:muting][mentioned_account_id] + should_filter ||= account&.user&.setting_hide_mntions_blocked && @preloaded_relations[:blocking] && @preloaded_relations[:blocking][mentioned_account_id] + if status.reply? + if status.private_visibility? + should_filter ||= (account&.user&.setting_hide_mntions_packm8 && @preloaded_relations[:following] && !@preloaded_relations[:following][mentioned_account_id]) + end + should_filter ||= account&.user&.setting_hide_mntions_blocker && Account.find(mentioned_account_id)&.blocking?(status.account_id) + end + should_filter end - return true if account.muting?(mentioned_account_ids) - # Same as above, but for blocks: - 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 - 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 + return true if account&.user&.setting_hide_mntions_packm8 && status.reply? && status.private_visibility? && (mentioned_account_ids - account.following_ids).any? + return true if account&.user&.setting_hide_mntions_muted && account.muting?(mentioned_account_ids) + account&.user&.setting_hide_mntions_blocked && account.blocking?(mentioned_account_ids) end def reply_to_blocked? diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index 650e290da..39e8a82fe 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -29,6 +29,7 @@ class UserSettingsDecorator 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['hide_mntions_packm8'] = hide_mntions_packm8_preference if change?('setting_hide_mntions_packm8') 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') @@ -97,6 +98,10 @@ class UserSettingsDecorator boolean_cast_setting 'setting_hide_mntions_blocker' end + def hide_mntions_packm8_preference + boolean_cast_setting 'setting_hide_mntions_packm8' + end + def gently_kobolds_preference boolean_cast_setting 'setting_gently_kobolds' end |