mirror of https://github.com/mastodon/mastodon
Merge 1d494abc6f
into 1959365c2f
This commit is contained in:
commit
f925a034b9
|
@ -40,9 +40,9 @@ class FeedManager
|
||||||
def filter?(timeline_type, status, receiver)
|
def filter?(timeline_type, status, receiver)
|
||||||
case timeline_type
|
case timeline_type
|
||||||
when :home
|
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
|
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
|
when :mentions
|
||||||
filter_from_mentions?(status, receiver.id)
|
filter_from_mentions?(status, receiver.id)
|
||||||
when :tags
|
when :tags
|
||||||
|
@ -52,6 +52,14 @@ class FeedManager
|
||||||
end
|
end
|
||||||
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
|
# Add a status to a home feed and send a streaming API update
|
||||||
# @param [Account] account
|
# @param [Account] account
|
||||||
# @param [Status] status
|
# @param [Status] status
|
||||||
|
@ -371,11 +379,12 @@ class FeedManager
|
||||||
# @param [Status] status
|
# @param [Status] status
|
||||||
# @param [Integer] receiver_id
|
# @param [Integer] receiver_id
|
||||||
# @param [Hash] crutches
|
# @param [Hash] crutches
|
||||||
|
# @param [Boolean] check_exclusive_list
|
||||||
# @return [Boolean]
|
# @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 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 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)
|
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] || []
|
check_for_blocks = crutches[:active_mentions][status.id] || []
|
||||||
|
|
|
@ -33,8 +33,9 @@ class FeedInsertWorker
|
||||||
perform_unpush if update?
|
perform_unpush if update?
|
||||||
else
|
else
|
||||||
perform_push
|
perform_push
|
||||||
perform_notify if notify?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
perform_notify if notify?
|
||||||
end
|
end
|
||||||
|
|
||||||
def feed_filtered?
|
def feed_filtered?
|
||||||
|
@ -49,7 +50,9 @@ class FeedInsertWorker
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify?
|
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?
|
Follow.find_by(account: @follower, target_account: @status.account)&.notify?
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe FeedInsertWorker do
|
||||||
|
|
||||||
context 'when there are real records' do
|
context 'when there are real records' do
|
||||||
it 'skips the push when there is a filter' 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)
|
allow(FeedManager).to receive(:instance).and_return(instance)
|
||||||
result = subject.perform(status.id, follower.id)
|
result = subject.perform(status.id, follower.id)
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ describe FeedInsertWorker do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'pushes the status onto the home timeline without filter' do
|
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)
|
allow(FeedManager).to receive(:instance).and_return(instance)
|
||||||
result = subject.perform(status.id, follower.id, :home)
|
result = subject.perform(status.id, follower.id, :home)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue