Fix to remove AccountSubscribe on block

This commit is contained in:
noellabo 2020-06-18 12:10:50 +09:00
parent 4fecd68d4c
commit f8657ee031
4 changed files with 12 additions and 1 deletions

View file

@ -14,6 +14,7 @@ class ActivityPub::Activity::Block < ActivityPub::Activity
UnfollowService.new.call(@account, target_account) if @account.following?(target_account)
UnfollowService.new.call(target_account, @account) if target_account.following?(@account)
RejectFollowService.new.call(target_account, @account) if target_account.requested?(@account)
UnsubscribeAccountService.new.call(target_account, @account, :all)
unless delete_arrived_first?(@json['id'])
BlockWorker.perform_async(@account.id, target_account.id)

View file

@ -359,6 +359,7 @@ class FeedManager
end
return true if check_for_blocks.any? { |target_account_id| crutches[:blocking][target_account_id] || crutches[:muting][target_account_id] }
return true if crutches[:blocked_by][status.account_id]
if status.reblog? # Filter out a reblog
should_filter = crutches[:hiding_reblogs][status.account_id] # if the reblogger's reblogs are suppressed
@ -580,7 +581,7 @@ class FeedManager
crutches[:muting] = Mute.where(account_id: receiver_id, target_account_id: check_for_blocks).pluck(:target_account_id).index_with(true)
crutches[:domain_blocking] = AccountDomainBlock.where(account_id: receiver_id, domain: statuses.map { |s| s.account&.domain }.compact).pluck(:domain).index_with(true)
crutches[:domain_blocking_r] = AccountDomainBlock.where(account_id: receiver_id, domain: statuses.map { |s| s.reblog&.account&.domain }.compact).pluck(:domain).index_with(true)
crutches[:blocked_by] = Block.where(target_account_id: receiver_id, account_id: statuses.map { |s| s.reblog&.account_id }.compact).pluck(:account_id).index_with(true)
crutches[:blocked_by] = Block.where(target_account_id: receiver_id, account_id: statuses.flat_map { |s| [s&.account_id, s.reblog&.account_id] }.compact).pluck(:account_id).index_with(true)
crutches[:following_tag_by] = FollowTag.where(account_id: receiver_id, tag: statuses.map { |s| s.tags }.flatten.uniq.compact).pluck(:tag_id).index_with(true)
crutches[:domain_subscribe] = DomainSubscribe.where(account_id: receiver_id, list_id: nil, domain: statuses.map { |s| s&.account&.domain }.compact).pluck(:domain).index_with(true)
crutches[:account_subscribe] = AccountSubscribe.where(account_id: receiver_id, target_account_id: statuses.map(&:account_id).compact).pluck(:target_account_id).index_with(true)

View file

@ -9,6 +9,8 @@ class BlockService < BaseService
UnfollowService.new.call(account, target_account) if account.following?(target_account)
UnfollowService.new.call(target_account, account) if target_account.following?(account)
RejectFollowService.new.call(target_account, account) if target_account.requested?(account)
UnsubscribeAccountService.new.call(account, target_account, :all)
UnsubscribeAccountService.new.call(target_account, account, :all)
block = account.block!(target_account)

View file

@ -5,6 +5,13 @@ class UnsubscribeAccountService < BaseService
# @param [Account] source_account Where to unsubscribe from
# @param [Account] target_account Which to unsubscribe
def call(source_account, target_account, list_id = nil)
if (list_id == :all)
AccountSubscribe.where(account: source_account, target_account: target_account).each do |subscribe|
subscribe.destroy!
UnmergeWorker.perform_async(target_account.id, source_account.id) if subscribe.list_id.nil?
end
end
subscribe = AccountSubscribe.find_by(account: source_account, target_account: target_account, list_id: list_id)
return unless subscribe