]> cat aescling's git repositories - mastodon.git/commitdiff
Merge pull request #858 from krainboltgreene/patch-6
authorEugen <eugen@zeonfederated.com>
Wed, 5 Apr 2017 00:53:39 +0000 (02:53 +0200)
committerGitHub <noreply@github.com>
Wed, 5 Apr 2017 00:53:39 +0000 (02:53 +0200)
Use active record shorthand

1  2 
app/lib/feed_manager.rb

index 28e7127049783e9f3733357e578e7eaa566ea77f,9398d6c700b09b8c1e255f5b50ff1660efb3d2db..2cca1cefe4f7a6a71fbb89e36edc2a748e8ff891
@@@ -116,14 -116,14 +116,14 @@@ class FeedManage
      false
    end
  
 -  def filter_from_mentions?(status, receiver)
 +  def filter_from_mentions?(status, receiver_id)
      check_for_blocks = [status.account_id]
-     check_for_blocks.concat(status.mentions.select('account_id').map(&:account_id))
+     check_for_blocks.concat(status.mentions.pluck(:account_id))
      check_for_blocks.concat([status.in_reply_to_account]) if status.reply? && !status.in_reply_to_account_id.nil?
  
 -    should_filter   = receiver.id == status.account_id                                      # Filter if I'm mentioning myself
 -    should_filter ||= receiver.blocking?(check_for_blocks)                                  # or it's from someone I blocked, in reply to someone I blocked, or mentioning someone I blocked
 -    should_filter ||= (status.account.silenced? && !receiver.following?(status.account))    # of if the account is silenced and I'm not following them
 +    should_filter   = receiver_id == status.account_id                                                                                   # Filter if I'm mentioning myself
 +    should_filter ||= Block.where(account_id: receiver_id, target_account_id: check_for_blocks).any?                                     # or it's from someone I blocked, in reply to someone I blocked, or mentioning someone I blocked
 +    should_filter ||= (status.account.silenced? && !Follow.where(account_id: receiver_id, target_account_id: status.account_id).exists?) # of if the account is silenced and I'm not following them
  
      should_filter
    end