mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Add after unblock domain from account service
This commit is contained in:
parent
25f9248ecd
commit
afc74a89b2
2 changed files with 18 additions and 0 deletions
|
@ -18,6 +18,8 @@ class AccountDomainBlock < ApplicationRecord
|
|||
belongs_to :account
|
||||
validates :domain, presence: true, uniqueness: { scope: :account_id }, domain: true
|
||||
|
||||
after_destroy :notify_streaming
|
||||
|
||||
after_commit :invalidate_domain_blocking_cache
|
||||
after_commit :invalidate_follow_recommendations_cache
|
||||
|
||||
|
@ -31,4 +33,8 @@ class AccountDomainBlock < ApplicationRecord
|
|||
def invalidate_follow_recommendations_cache
|
||||
Rails.cache.delete("follow_recommendations/#{account_id}")
|
||||
end
|
||||
|
||||
def notify_streaming
|
||||
AfterUnblockDomainFromAccountService.call(account_id, domain)
|
||||
end
|
||||
end
|
||||
|
|
12
app/services/after_unblock_domain_from_account_service.rb
Normal file
12
app/services/after_unblock_domain_from_account_service.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AfterUnblockDomainFromAccountService < BaseService
|
||||
include Redisable
|
||||
|
||||
# This service does not delete an AccountDomainBlock record,
|
||||
# it's meant to be called after such a record has been created
|
||||
# synchronously, to "clean up"
|
||||
def call(account, domain)
|
||||
redis.publish('system', Oj.dump(event: :domain_blocks_changed, account: account.id, target_domain: domain))
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue