mirror of
https://github.com/mastodon/mastodon.git
synced 2024-05-19 10:28:08 +00:00
Merge 1d494abc6f
into 5cd13ee4f1
This commit is contained in:
commit
2dce5ca57a
|
@ -40,9 +40,9 @@ class FeedManager
|
|||
def filter?(timeline_type, status, receiver)
|
||||
case timeline_type
|
||||
when :home
|
||||
filter_from_home?(status, receiver.id, build_crutches(receiver.id, [status]), :home)
|
||||
filter_from_home?(status, receiver.id, build_crutches(receiver.id, [status]), check_exclusive_list: true)
|
||||
when :list
|
||||
filter_from_list?(status, receiver) || filter_from_home?(status, receiver.account_id, build_crutches(receiver.account_id, [status]), :list)
|
||||
filter_from_list?(status, receiver) || filter_from_home?(status, receiver.account_id, build_crutches(receiver.account_id, [status]), check_exclusive_list: false)
|
||||
when :mentions
|
||||
filter_from_mentions?(status, receiver.id)
|
||||
when :tags
|
||||
|
@ -52,6 +52,14 @@ class FeedManager
|
|||
end
|
||||
end
|
||||
|
||||
# Check if the status should be filtered from notifications
|
||||
# @param [Status] status
|
||||
# @param [Integer] account_id
|
||||
# @return [Boolean]
|
||||
def filter_notification?(account_id, status)
|
||||
filter_from_home?(status, account_id, build_crutches(account_id, [status]), check_exclusive_list: false)
|
||||
end
|
||||
|
||||
# Add a status to a home feed and send a streaming API update
|
||||
# @param [Account] account
|
||||
# @param [Status] status
|
||||
|
@ -371,11 +379,12 @@ class FeedManager
|
|||
# @param [Status] status
|
||||
# @param [Integer] receiver_id
|
||||
# @param [Hash] crutches
|
||||
# @param [Boolean] check_exclusive_list
|
||||
# @return [Boolean]
|
||||
def filter_from_home?(status, receiver_id, crutches, timeline_type = :home)
|
||||
def filter_from_home?(status, receiver_id, crutches, check_exclusive_list: true)
|
||||
return false if receiver_id == status.account_id
|
||||
return true if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)
|
||||
return true if timeline_type != :list && crutches[:exclusive_list_users][status.account_id].present?
|
||||
return true if check_exclusive_list && crutches[:exclusive_list_users][status.account_id].present?
|
||||
return true if crutches[:languages][status.account_id].present? && status.language.present? && !crutches[:languages][status.account_id].include?(status.language)
|
||||
|
||||
check_for_blocks = crutches[:active_mentions][status.id] || []
|
||||
|
|
|
@ -33,8 +33,9 @@ class FeedInsertWorker
|
|||
perform_unpush if update?
|
||||
else
|
||||
perform_push
|
||||
perform_notify if notify?
|
||||
end
|
||||
|
||||
perform_notify if notify?
|
||||
end
|
||||
|
||||
def feed_filtered?
|
||||
|
@ -49,7 +50,9 @@ class FeedInsertWorker
|
|||
end
|
||||
|
||||
def notify?
|
||||
return false if @type != :home || @status.reblog? || (@status.reply? && @status.in_reply_to_account_id != @status.account_id)
|
||||
return false if @type != :home || @status.reblog? ||
|
||||
(@status.reply? && @status.in_reply_to_account_id != @status.account_id) ||
|
||||
FeedManager.instance.filter_notification?(@status.account_id, @status)
|
||||
|
||||
Follow.find_by(account: @follower, target_account: @status.account)&.notify?
|
||||
end
|
||||
|
|
|
@ -32,7 +32,7 @@ describe FeedInsertWorker do
|
|||
|
||||
context 'when there are real records' do
|
||||
it 'skips the push when there is a filter' do
|
||||
instance = instance_double(FeedManager, push_to_home: nil, filter?: true)
|
||||
instance = instance_double(FeedManager, push_to_home: nil, filter?: true, filter_notification?: true)
|
||||
allow(FeedManager).to receive(:instance).and_return(instance)
|
||||
result = subject.perform(status.id, follower.id)
|
||||
|
||||
|
@ -41,7 +41,7 @@ describe FeedInsertWorker do
|
|||
end
|
||||
|
||||
it 'pushes the status onto the home timeline without filter' do
|
||||
instance = instance_double(FeedManager, push_to_home: nil, filter?: false)
|
||||
instance = instance_double(FeedManager, push_to_home: nil, filter?: false, filter_notification?: false)
|
||||
allow(FeedManager).to receive(:instance).and_return(instance)
|
||||
result = subject.perform(status.id, follower.id, :home)
|
||||
|
||||
|
|
Loading…
Reference in a new issue