]> cat aescling's git repositories - mastodon.git/commitdiff
guard against empty domain block list in status scope (#3161)
authorbeatrix <beatrix.bitrot@gmail.com>
Sat, 20 May 2017 11:38:13 +0000 (07:38 -0400)
committerEugen Rochko <eugen@zeonfederated.com>
Sat, 20 May 2017 11:38:13 +0000 (13:38 +0200)
app/models/status.rb

index 88bfd1748aa2c6fad68135fc1af5ff3a2670028f..a4e581a066923a61bc7e23a47c494e3804cf46a1 100644 (file)
@@ -68,7 +68,7 @@ class Status < ApplicationRecord
   scope :excluding_silenced_accounts, -> { left_outer_joins(:account).where(accounts: { silenced: false }) }
   scope :including_silenced_accounts, -> { left_outer_joins(:account).where(accounts: { silenced: true }) }
   scope :not_excluded_by_account, ->(account) { where.not(account_id: account.excluded_from_timeline_account_ids) }
-  scope :not_domain_blocked_by_account, ->(account) { left_outer_joins(:account).where('accounts.domain IS NULL OR accounts.domain NOT IN (?)', account.excluded_from_timeline_domains) }
+  scope :not_domain_blocked_by_account, ->(account) { account.excluded_from_timeline_domains.blank? ? left_outer_joins(:account) : left_outer_joins(:account).where('accounts.domain IS NULL OR accounts.domain NOT IN (?)', account.excluded_from_timeline_domains) }
 
   cache_associated :account, :application, :media_attachments, :tags, :stream_entry, mentions: :account, reblog: [:account, :application, :stream_entry, :tags, :media_attachments, mentions: :account], thread: :account