about summary refs log tree commit diff
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-05-09 12:24:08 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:23 -0500
commit5c59d1837f2d3152342ef45bf7827495183e62dd (patch)
tree0a29c58ef906a2f67e91321d977c8142f0f1281f
parent0782dc390525c5d1db66ea53e1208689c7d0bfcb (diff)
Make user settings for status filter accessible from `account` model.
-rw-r--r--app/lib/status_filter.rb22
-rw-r--r--app/models/account.rb7
2 files changed, 18 insertions, 11 deletions
diff --git a/app/lib/status_filter.rb b/app/lib/status_filter.rb
index 6247ca607..23c2fb236 100644
--- a/app/lib/status_filter.rb
+++ b/app/lib/status_filter.rb
@@ -28,9 +28,9 @@ class StatusFilter
 
   def filtered_reference?
     # filter muted/blocked
-    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?
+    return true if account.user_hide_replies_of_blocked? && reply_to_blocked?
+    return true if account.user_hide_replies_of_muted? && reply_to_muted?
+    return true if account.user_hide_replies_of_blocker? && reply_to_blocker?
 
     # kajiht has no filters if status has no mentions
     return false if status&.mentions.blank?
@@ -42,22 +42,22 @@ class StatusFilter
     return false if mentioned_account_ids.include?(account.id)
 
     return true if mentioned_account_ids.any? do |mentioned_account_id|
-      return true if @preloaded_relations[:muting] && account&.user&.setting_hide_mntions_muted && @preloaded_relations[:muting][mentioned_account_id]
-      return true if @preloaded_relations[:blocking] && account&.user&.setting_hide_mntions_blocked && @preloaded_relations[:blocking][mentioned_account_id]
+      return true if @preloaded_relations[:muting] && account.user_hide_mentions_of_muted? && @preloaded_relations[:muting][mentioned_account_id]
+      return true if @preloaded_relations[:blocking] && account.user_hide_mentions_of_blocked? && @preloaded_relations[:blocking][mentioned_account_id]
 
       if @preloaded_relations[:blocked_by]
-        return true if account&.user&.setting_hide_mntions_blocker && @preloaded_relations[:blocked_by][mentioned_account_id]
+        return true if account.user_hide_mentions_of_blocker? && @preloaded_relations[:blocked_by][mentioned_account_id]
       else
-        return true if account&.user&.setting_hide_mntions_blocker && Account.find(mentioned_account_id)&.blocking?(account.id)
+        return true if account.user_hide_mentions_of_blocker? && Account.find(mentioned_account_id)&.blocking?(account.id)
       end
 
       return false unless status.private_visibility? && status.reply?
-      @preloaded_relations[:following] && account&.user&.setting_hide_mntions_packm8 && !@preloaded_relations[:following][mentioned_account_id]
+      @preloaded_relations[:following] && account.user_hide_mentions_outside_scope? && !@preloaded_relations[:following][mentioned_account_id]
     end
 
-    return true if !@preloaded_relations[:following] && account&.user&.setting_hide_mntions_packm8 && status.private_visibility? && status.reply? && (mentioned_account_ids - account.following_ids).any?
-    return true if !@preloaded_relations[:muting] && account&.user&.setting_hide_mntions_muted && account.muting?(mentioned_account_ids)
-    return true if !@preloaded_relations[:blocking] && account&.user&.setting_hide_mntions_blocked && account.blocking?(mentioned_account_ids)
+    return true if !@preloaded_relations[:following] && account.user_hide_mentions_outside_scope? && status.private_visibility? && status.reply? && (mentioned_account_ids - account.following_ids).any?
+    return true if !@preloaded_relations[:muting] && account.user_hide_mentions_of_muted? && account.muting?(mentioned_account_ids)
+    return true if !@preloaded_relations[:blocking] && account.user_hide_mentions_of_blocked? && account.blocking?(mentioned_account_ids)
   end
 
   def reply_to_blocked?
diff --git a/app/models/account.rb b/app/models/account.rb
index 0b647a965..6e7cf3773 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -125,6 +125,13 @@ class Account < ApplicationRecord
            :always_local?,
            :default_local?,
            :no_blabber_blocks?,
+           :hide_replies_of_muted?,
+           :hide_replies_of_blocked?,
+           :hide_replies_of_blocker?,
+           :hide_mntions_of_muted?,
+           :hide_mntions_of_blocked?,
+           :hide_mntions_of_blocker?,
+           :hide_mntions_of_outside_scope?,
            to: :user,
            prefix: true,
            allow_nil: true