chore: Improve the reauthorization requirement for Email Channel (#4753)
This commit is contained in:
@@ -36,6 +36,8 @@ class Channel::Email < ApplicationRecord
|
||||
include Channelable
|
||||
include Reauthorizable
|
||||
|
||||
AUTHORIZATION_ERROR_THRESHOLD = 10
|
||||
|
||||
self.table_name = 'channel_email'
|
||||
EDITABLE_ATTRS = [:email, :imap_enabled, :imap_login, :imap_password, :imap_address, :imap_port, :imap_enable_ssl, :imap_inbox_synced_at,
|
||||
:smtp_enabled, :smtp_login, :smtp_password, :smtp_address, :smtp_port, :smtp_domain, :smtp_enable_starttls_auto,
|
||||
|
||||
@@ -29,7 +29,9 @@ module Reauthorizable
|
||||
# Implement in your exception handling logic for authorization errors
|
||||
def authorization_error!
|
||||
::Redis::Alfred.incr(authorization_error_count_key)
|
||||
prompt_reauthorization! if authorization_error_count >= AUTHORIZATION_ERROR_THRESHOLD
|
||||
# we are giving precendence to the authorization error threshhold defined in the class
|
||||
# so that channels can override the default value
|
||||
prompt_reauthorization! if authorization_error_count >= self.class::AUTHORIZATION_ERROR_THRESHOLD
|
||||
end
|
||||
|
||||
# Performed automatically if error threshold is breached
|
||||
|
||||
Reference in New Issue
Block a user