about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-12-26 19:13:56 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-12-26 19:13:56 +0100
commit7376af90f79b1de0c4cdd294f3f4d1481eedf0d7 (patch)
treef3c038fae202b59b50613b4f94899ad0b3291a74 /app/models
parent3282448878dd2640ea47dc1a77a4ae958ba8923e (diff)
Don't show statuses to blocked users
Diffstat (limited to 'app/models')
-rw-r--r--app/models/status.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index dc7fc60d7..1720d754a 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -31,7 +31,6 @@ class Status < ApplicationRecord
 
   scope :remote, -> { where.not(uri: nil) }
   scope :local, -> { where(uri: nil) }
-  scope :permitted_for, ->(target_account, account) { account&.id == target_account.id || account&.following?(target_account) ? where('1=1') : where.not(visibility: :private) }
 
   cache_associated :account, :media_attachments, :tags, :stream_entry, mentions: :account, reblog: [:account, :stream_entry, :tags, :media_attachments, mentions: :account], thread: :account
 
@@ -72,7 +71,7 @@ class Status < ApplicationRecord
   end
 
   def permitted?(other_account = nil)
-    private_visibility? ? (account.id == other_account&.id || other_account&.following?(account)) : true
+    private_visibility? ? (account.id == other_account&.id || other_account&.following?(account)) : other_account.nil? || !account.blocking?(other_account)
   end
 
   def ancestors(account = nil)
@@ -145,6 +144,16 @@ class Status < ApplicationRecord
       end
     end
 
+    def permitted_for(target_account, account)
+      if account&.id == target_account.id || account&.following?(target_account)
+        where('1 = 1')
+      elsif !account.nil? && target_account.blocking?(account)
+        where('1 = 0')
+      else
+        where.not(visibility: :private)
+      end
+    end
+
     private
 
     def filter_timeline(query, account)