diff --git a/app/lib/activitypub/activity/block.rb b/app/lib/activitypub/activity/block.rb index 92a0f813f..65b1edd5a 100644 --- a/app/lib/activitypub/activity/block.rb +++ b/app/lib/activitypub/activity/block.rb @@ -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) diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index ddaf4f257..c661c5217 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -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) diff --git a/app/services/block_service.rb b/app/services/block_service.rb index 266a0f4b9..9deb91d76 100644 --- a/app/services/block_service.rb +++ b/app/services/block_service.rb @@ -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) diff --git a/app/services/unsubscribe_account_service.rb b/app/services/unsubscribe_account_service.rb index 0be351325..939cbe5b8 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