diff --git a/app/services/after_block_domain_from_account_service.rb b/app/services/after_block_domain_from_account_service.rb index fc5dc656810..207225aac9a 100644 --- a/app/services/after_block_domain_from_account_service.rb +++ b/app/services/after_block_domain_from_account_service.rb @@ -16,7 +16,9 @@ class AfterBlockDomainFromAccountService < BaseService remove_follows! reject_existing_followers! reject_pending_follow_requests! + notify_of_severed_relationships! + notify_streaming! end private @@ -67,4 +69,8 @@ class AfterBlockDomainFromAccountService < BaseService def domain_block_event @domain_block_event ||= RelationshipSeveranceEvent.create!(type: :user_domain_block, target_name: @domain) end + + def notify_streaming! + redis.publish('system', Oj.dump(event: :domain_blocks_changed, account: @account.id, target_domain: @domain)) + end end diff --git a/app/services/after_block_service.rb b/app/services/after_block_service.rb index 899e84be44f..26e6218c296 100644 --- a/app/services/after_block_service.rb +++ b/app/services/after_block_service.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class AfterBlockService < BaseService + include Redisable + def call(account, target_account) @account = account @target_account = target_account @@ -9,6 +11,7 @@ class AfterBlockService < BaseService clear_list_feeds! clear_notifications! clear_conversations! + notify_streaming! end private @@ -28,4 +31,8 @@ class AfterBlockService < BaseService def clear_notifications! Notification.where(account: @account).where(from_account: @target_account).in_batches.delete_all end + + def notify_streaming! + redis.publish('system', Oj.dump(event: :blocks_changed, account: @account.id, target_account: @target_account.id)) + end end diff --git a/app/services/unblock_service.rb b/app/services/unblock_service.rb index c263ac8afe0..72e63f7c99a 100644 --- a/app/services/unblock_service.rb +++ b/app/services/unblock_service.rb @@ -8,6 +8,9 @@ class UnblockService < BaseService unblock = account.unblock!(target_account) create_notification(unblock) if !target_account.local? && target_account.activitypub? + + notify_streaming! + unblock end @@ -20,4 +23,8 @@ class UnblockService < BaseService def build_json(unblock) Oj.dump(serialize_payload(unblock, ActivityPub::UndoBlockSerializer)) end + + def notify_streaming! + redis.publish('system', Oj.dump(event: :blocks_changed, account: @account.id, target_account: @target_account.id)) + end end diff --git a/app/services/unmute_service.rb b/app/services/unmute_service.rb index 6aeea358f75..7a825f65db0 100644 --- a/app/services/unmute_service.rb +++ b/app/services/unmute_service.rb @@ -7,5 +7,13 @@ class UnmuteService < BaseService account.unmute!(target_account) MergeWorker.perform_async(target_account.id, account.id) if account.following?(target_account) + + notify_streaming! + end + + private + + def notify_streaming! + redis.publish('system', Oj.dump(event: :mutes_changed, account: @account.id, target_account: @target_account.id)) end end diff --git a/app/workers/mute_worker.rb b/app/workers/mute_worker.rb index c74f657cbac..47aeaf1990f 100644 --- a/app/workers/mute_worker.rb +++ b/app/workers/mute_worker.rb @@ -2,10 +2,25 @@ class MuteWorker include Sidekiq::Worker + include Redisable def perform(account_id, target_account_id) - FeedManager.instance.clear_from_home(Account.find(account_id), Account.find(target_account_id)) + @account = Account.find(account_id) + @target_account = Account.find(target_account_id) + + clear_home_feed! + notify_streaming! rescue ActiveRecord::RecordNotFound true end + + private + + def clear_home_feed! + FeedManager.instance.clear_from_home(@account, @target_account) + end + + def notify_streaming! + redis.publish('system', Oj.dump(event: :mutes_changed, account: @account.id, target_account: @target_account.id)) + end end