diff --git a/app/lib/activitypub/activity/block.rb b/app/lib/activitypub/activity/block.rb index 90477bf3369dca..9c708659fe786b 100644 --- a/app/lib/activitypub/activity/block.rb +++ b/app/lib/activitypub/activity/block.rb @@ -12,6 +12,7 @@ def perform end UnfollowService.new.call(target_account, @account) if target_account.following?(@account) + UnsubscribeAccountService.new.call(target_account, @account, :all) @account.block!(target_account, uri: @json['id']) unless delete_arrived_first?(@json['id']) end diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index 76d090762cc196..20fa6fb85ead94 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -299,6 +299,7 @@ def filter_from_home?(status, receiver_id, crutches) 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 @@ -520,7 +521,7 @@ def build_crutches(receiver_id, statuses) crutches[:muting] = Mute.where(account_id: receiver_id, target_account_id: check_for_blocks).pluck(:target_account_id).each_with_object({}) { |id, mapping| mapping[id] = true } crutches[:domain_blocking] = AccountDomainBlock.where(account_id: receiver_id, domain: statuses.map { |s| s.account&.domain }.compact).pluck(:domain).each_with_object({}) { |domain, mapping| mapping[domain] = true } crutches[:domain_blocking_r] = AccountDomainBlock.where(account_id: receiver_id, domain: statuses.map { |s| s.reblog&.account&.domain }.compact).pluck(:domain).each_with_object({}) { |domain, mapping| mapping[domain] = true } - crutches[:blocked_by] = Block.where(target_account_id: receiver_id, account_id: statuses.map { |s| s.reblog&.account_id }.compact).pluck(:account_id).each_with_object({}) { |id, mapping| mapping[id] = 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).each_with_object({}) { |id, mapping| mapping[id] = true } crutches[:following_tag_by] = FollowTag.where(account_id: receiver_id, tag: statuses.map { |s| s.tags }.flatten.uniq.compact).pluck(:tag_id).each_with_object({}) { |tag_id, mapping| mapping[tag_id] = true } crutches[:domain_subscribe] = DomainSubscribe.where(account_id: receiver_id, list_id: nil, domain: statuses.map { |s| s&.account&.domain }.compact).pluck(:domain).each_with_object({}) { |domain, mapping| mapping[domain] = true } crutches[:account_subscribe] = AccountSubscribe.where(account_id: receiver_id, target_account_id: statuses.map(&:account_id).compact).pluck(:target_account_id).each_with_object({}) { |id, mapping| mapping[id] = true } diff --git a/app/services/block_service.rb b/app/services/block_service.rb index 266a0f4b9d0384..9deb91d76c4b26 100644 --- a/app/services/block_service.rb +++ b/app/services/block_service.rb @@ -9,6 +9,8 @@ def call(account, target_account) 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) diff --git a/app/services/unsubscribe_account_service.rb b/app/services/unsubscribe_account_service.rb index 0be351325629f0..939cbe5b8b31c2 100644 --- a/app/services/unsubscribe_account_service.rb +++ b/app/services/unsubscribe_account_service.rb @@ -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