1
0
Fork 0
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:
Emelia Smith 2024-07-09 21:46:23 +02:00
parent 25f9248ecd
commit afc74a89b2
No known key found for this signature in database
2 changed files with 18 additions and 0 deletions

View file

@ -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

View 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