adjust email configs loading
This commit is contained in:
committed by
Pete Matsyburka
parent
3575a25935
commit
0698aad8e1
@@ -8,7 +8,7 @@ class SubmitterMailer < ApplicationMailer
|
||||
@submitter = submitter
|
||||
@body = body.presence
|
||||
|
||||
@email_config = @current_account.account_configs.find_by(key: AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY)
|
||||
@email_config = AccountConfigs.find_for_account(@current_account, AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY)
|
||||
|
||||
subject =
|
||||
if @email_config || subject.present?
|
||||
@@ -31,7 +31,7 @@ class SubmitterMailer < ApplicationMailer
|
||||
|
||||
Submissions::EnsureResultGenerated.call(submitter)
|
||||
|
||||
@email_config = @current_account.account_configs.find_by(key: AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY)
|
||||
@email_config = AccountConfigs.find_for_account(@current_account, AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY)
|
||||
|
||||
add_completed_email_attachments!(submitter)
|
||||
|
||||
@@ -58,7 +58,7 @@ class SubmitterMailer < ApplicationMailer
|
||||
|
||||
@documents = add_completed_email_attachments!(submitter)
|
||||
|
||||
@email_config = @current_account.account_configs.find_by(key: AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY)
|
||||
@email_config = AccountConfigs.find_for_account(@current_account, AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY)
|
||||
|
||||
subject =
|
||||
if @email_config
|
||||
|
||||
@@ -17,7 +17,15 @@ module AccountConfigs
|
||||
module_function
|
||||
|
||||
def find_or_initialize_for_key(account, key)
|
||||
account.account_configs.find_by(key:) ||
|
||||
find_for_account(account, key) ||
|
||||
account.account_configs.new(key:, value: AccountConfig::DEFAULT_VALUES[key])
|
||||
end
|
||||
|
||||
def find_for_account(account, key)
|
||||
configs = account.account_configs.find_by(key:)
|
||||
|
||||
configs ||= Account.order(:id).first.account_configs.find_by(key:) unless Docuseal.multitenant?
|
||||
|
||||
configs
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user