diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/settings/preferences_controller.rb | 1 | ||||
-rw-r--r-- | app/lib/status_filter.rb | 29 | ||||
-rw-r--r-- | app/lib/user_settings_decorator.rb | 5 | ||||
-rw-r--r-- | app/models/user.rb | 5 | ||||
-rw-r--r-- | app/views/settings/preferences/show.html.haml | 1 |
5 files changed, 26 insertions, 15 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 85fc062d5..f71cbb1fe 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -44,6 +44,7 @@ class Settings::PreferencesController < Settings::BaseController :setting_hide_mntions_muted, :setting_hide_mntions_blocked, :setting_hide_mntions_blocker, + :setting_hide_mntions_packm8, :setting_gently_kobolds, :setting_user_is_kobold, 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 diff --git a/app/models/user.rb b/app/models/user.rb index 29db2e078..b4328afcb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -118,6 +118,7 @@ class User < ApplicationRecord :hide_mntions_muted, :hide_mntions_blocked, :hide_mntions_blocker, + :hide_mntions_packm8, :gently_kobolds, :user_is_kobold, @@ -262,6 +263,10 @@ class User < ApplicationRecord settings.hide_mntions_blocker || true end + def setting_hide_mntions_packm8 + settings.hide_mntions_packm8 || 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 48d28e17d..634cd53ff 100644 --- a/app/views/settings/preferences/show.html.haml +++ b/app/views/settings/preferences/show.html.haml @@ -70,6 +70,7 @@ = 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 + = f.input :setting_hide_mntions_packm8, as: :boolean, wrapper: :with_label .fields-group = f.input :setting_unfollow_modal, as: :boolean, wrapper: :with_label |