refactor: reset cache keys when channel is unauthorized

This commit is contained in:
Shivam Mishra
2024-05-21 13:21:23 +05:30
parent 00dca9466a
commit 46e69ffff2
+7
View File
@@ -54,6 +54,8 @@ module Reauthorizable
update!(active: false)
mailer.automation_rule_disabled(self).deliver_later
end
update_cache_keys unless instance_of?(::AutomationRule)
end
def process_integration_hook_reauthorization_emails(mailer)
@@ -68,10 +70,15 @@ module Reauthorizable
def reauthorized!
::Redis::Alfred.delete(authorization_error_count_key)
::Redis::Alfred.delete(reauthorization_required_key)
update_cache_keys
end
private
def update_cache_keys
inbox.update_account_cache if inbox.present?
end
def authorization_error_count_key
format(::Redis::Alfred::AUTHORIZATION_ERROR_COUNT, obj_type: self.class.table_name.singularize, obj_id: id)
end