about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-10-09 15:15:21 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-10-09 15:15:21 +0200
commit427ba276413a268939d8e93337168cdb02b2f684 (patch)
treef13fe6a62a89882d11d884fdcdd197cf10bd4f17 /app/models
parent769b1ebbe0de2e3c9929add50bc18718055690d1 (diff)
Public timeline to exclude users you blocked
Diffstat (limited to 'app/models')
-rw-r--r--app/models/status.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 7ff0487a3..111172e9a 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -18,6 +18,8 @@ class Status < ApplicationRecord
   validates :text, presence: true, length: { maximum: 500 }, if: proc { |s| s.local? && !s.reblog? }
   validates :reblog, uniqueness: { scope: :account, message: 'of status already exists' }, if: 'reblog?'
 
+  default_scope { order('id desc') }
+
   scope :with_counters, -> { select('statuses.*, (select count(r.id) from statuses as r where r.reblog_of_id = statuses.id) as reblogs_count, (select count(f.id) from favourites as f where f.status_id = statuses.id) as favourites_count') }
   scope :with_includes, -> { includes(:account, :media_attachments, :stream_entry, mentions: :account, reblog: [:account, mentions: :account], thread: :account) }
 
@@ -83,6 +85,10 @@ class Status < ApplicationRecord
     where(id: Mention.where(account: account).pluck(:status_id)).with_includes.with_counters
   end
 
+  def self.as_public_timeline(account)
+    where.not(account_id: account.blocking).with_includes.with_counters
+  end
+
   def self.favourites_map(status_ids, account_id)
     Favourite.where(status_id: status_ids).where(account_id: account_id).map { |f| [f.status_id, true] }.to_h
   end