mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Implement system channel events for blocks, domain_blocks and mutes
This commit is contained in:
parent
209376306b
commit
b12b27663a
5 changed files with 44 additions and 1 deletions
|
@ -16,7 +16,9 @@ class AfterBlockDomainFromAccountService < BaseService
|
||||||
remove_follows!
|
remove_follows!
|
||||||
reject_existing_followers!
|
reject_existing_followers!
|
||||||
reject_pending_follow_requests!
|
reject_pending_follow_requests!
|
||||||
|
|
||||||
notify_of_severed_relationships!
|
notify_of_severed_relationships!
|
||||||
|
notify_streaming!
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -67,4 +69,8 @@ class AfterBlockDomainFromAccountService < BaseService
|
||||||
def domain_block_event
|
def domain_block_event
|
||||||
@domain_block_event ||= RelationshipSeveranceEvent.create!(type: :user_domain_block, target_name: @domain)
|
@domain_block_event ||= RelationshipSeveranceEvent.create!(type: :user_domain_block, target_name: @domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notify_streaming!
|
||||||
|
redis.publish('system', Oj.dump(event: :domain_blocks_changed, account: @account.id, target_domain: @domain))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AfterBlockService < BaseService
|
class AfterBlockService < BaseService
|
||||||
|
include Redisable
|
||||||
|
|
||||||
def call(account, target_account)
|
def call(account, target_account)
|
||||||
@account = account
|
@account = account
|
||||||
@target_account = target_account
|
@target_account = target_account
|
||||||
|
@ -9,6 +11,7 @@ class AfterBlockService < BaseService
|
||||||
clear_list_feeds!
|
clear_list_feeds!
|
||||||
clear_notifications!
|
clear_notifications!
|
||||||
clear_conversations!
|
clear_conversations!
|
||||||
|
notify_streaming!
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -28,4 +31,8 @@ class AfterBlockService < BaseService
|
||||||
def clear_notifications!
|
def clear_notifications!
|
||||||
Notification.where(account: @account).where(from_account: @target_account).in_batches.delete_all
|
Notification.where(account: @account).where(from_account: @target_account).in_batches.delete_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notify_streaming!
|
||||||
|
redis.publish('system', Oj.dump(event: :blocks_changed, account: @account.id, target_account: @target_account.id))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,9 @@ class UnblockService < BaseService
|
||||||
|
|
||||||
unblock = account.unblock!(target_account)
|
unblock = account.unblock!(target_account)
|
||||||
create_notification(unblock) if !target_account.local? && target_account.activitypub?
|
create_notification(unblock) if !target_account.local? && target_account.activitypub?
|
||||||
|
|
||||||
|
notify_streaming!
|
||||||
|
|
||||||
unblock
|
unblock
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -20,4 +23,8 @@ class UnblockService < BaseService
|
||||||
def build_json(unblock)
|
def build_json(unblock)
|
||||||
Oj.dump(serialize_payload(unblock, ActivityPub::UndoBlockSerializer))
|
Oj.dump(serialize_payload(unblock, ActivityPub::UndoBlockSerializer))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notify_streaming!
|
||||||
|
redis.publish('system', Oj.dump(event: :blocks_changed, account: @account.id, target_account: @target_account.id))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,5 +7,13 @@ class UnmuteService < BaseService
|
||||||
account.unmute!(target_account)
|
account.unmute!(target_account)
|
||||||
|
|
||||||
MergeWorker.perform_async(target_account.id, account.id) if account.following?(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
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,25 @@
|
||||||
|
|
||||||
class MuteWorker
|
class MuteWorker
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
include Redisable
|
||||||
|
|
||||||
def perform(account_id, target_account_id)
|
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
|
rescue ActiveRecord::RecordNotFound
|
||||||
true
|
true
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue