mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Fix subsequent replies to unresolved status not being filtered from home (#4190)
Resolves #4177 - smaller changeset
This commit is contained in:
parent
72bd73f605
commit
de397f3bc1
2 changed files with 11 additions and 3 deletions
|
@ -93,7 +93,7 @@ class FeedManager
|
|||
end
|
||||
|
||||
def filter_from_home?(status, receiver_id)
|
||||
return true if status.reply? && status.in_reply_to_id.nil?
|
||||
return true if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)
|
||||
|
||||
check_for_mutes = [status.account_id]
|
||||
check_for_mutes.concat([status.reblog.account_id]) if status.reblog?
|
||||
|
@ -120,12 +120,13 @@ class FeedManager
|
|||
end
|
||||
|
||||
def filter_from_mentions?(status, receiver_id)
|
||||
return true if receiver_id == status.account_id
|
||||
|
||||
check_for_blocks = [status.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 ||= 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 = Block.where(account_id: receiver_id, target_account_id: check_for_blocks).any? # Filter if 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
|
||||
|
|
|
@ -81,6 +81,13 @@ RSpec.describe FeedManager do
|
|||
expect(FeedManager.instance.filter?(:home, reply, bob.id)).to be true
|
||||
end
|
||||
|
||||
it 'returns true for the second reply by followee to a non-federated status' do
|
||||
reply = Fabricate(:status, text: 'Reply 1', reply: true, account: alice)
|
||||
second_reply = Fabricate(:status, text: 'Reply 2', thread: reply, account: alice)
|
||||
bob.follow!(alice)
|
||||
expect(FeedManager.instance.filter?(:home, second_reply, bob.id)).to be true
|
||||
end
|
||||
|
||||
it 'returns false for status by followee mentioning another account' do
|
||||
bob.follow!(alice)
|
||||
status = PostStatusService.new.call(alice, 'Hey @jeff')
|
||||
|
|
Loading…
Reference in a new issue