about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-12-05 22:59:30 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-12-05 22:59:30 +0100
commit39cc9fde8a2e34da0639d83688d4d6d6d6240382 (patch)
tree2f41f57b6e21dacbb6dd67b8db73a5fac4a08493 /app/models/status.rb
parent64d109dc0e39574d4ed45f2443ee132dfb761033 (diff)
Add account suspension
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 1f5cf9b46..9d1dae963 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -104,22 +104,20 @@ class Status < ApplicationRecord
     def as_public_timeline(account = nil)
       query = joins('LEFT OUTER JOIN accounts ON statuses.account_id = accounts.id')
               .where(visibility: :public)
-              .where('accounts.silenced = FALSE')
               .where('(statuses.in_reply_to_id IS NULL OR statuses.in_reply_to_account_id = statuses.account_id)')
               .where('statuses.reblog_of_id IS NULL')
-      query = filter_timeline(query, account) unless account.nil?
-      query
+
+      account.nil? ? filter_timeline_default(query) : filter_timeline(query, account)
     end
 
     def as_tag_timeline(tag, account = nil)
       query = tag.statuses
                  .joins('LEFT OUTER JOIN accounts ON statuses.account_id = accounts.id')
                  .where(visibility: :public)
-                 .where('accounts.silenced = FALSE')
                  .where('(statuses.in_reply_to_id IS NULL OR statuses.in_reply_to_account_id = statuses.account_id)')
                  .where('statuses.reblog_of_id IS NULL')
-      query = filter_timeline(query, account) unless account.nil?
-      query
+
+      account.nil? ? filter_timeline_default(query) : filter_timeline(query, account)
     end
 
     def favourites_map(status_ids, account_id)
@@ -150,8 +148,13 @@ class Status < ApplicationRecord
 
     def filter_timeline(query, account)
       blocked = Block.where(account: account).pluck(:target_account_id)
-      return query if blocked.empty?
-      query.where('statuses.account_id NOT IN (?)', blocked)
+      query   = query.where('statuses.account_id NOT IN (?)', blocked) unless blocked.empty?
+      query   = query.where('accounts.silenced = TRUE') if account.silenced?
+      query
+    end
+
+    def filter_timeline_default(query)
+      query.where('accounts.silenced = FALSE')
     end
   end