i18n emails
This commit is contained in:
committed by
Oleksandr Turchyn
parent
e6c20f5ff6
commit
2f530ccfca
@@ -4,8 +4,6 @@ class SubmitterMailer < ApplicationMailer
|
||||
MAX_ATTACHMENTS_SIZE = 10.megabytes
|
||||
SIGN_TTL = 1.hour + 20.minutes
|
||||
|
||||
DEFAULT_INVITATION_SUBJECT = 'You are invited to submit a form'
|
||||
|
||||
NO_REPLY_REGEXP = /no-?reply@/i
|
||||
|
||||
def invitation_email(submitter)
|
||||
@@ -21,17 +19,19 @@ class SubmitterMailer < ApplicationMailer
|
||||
|
||||
@email_config = AccountConfigs.find_for_account(@current_account, AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY)
|
||||
|
||||
subject =
|
||||
if @email_config || @subject
|
||||
ReplaceEmailVariables.call(@subject || @email_config.value['subject'], submitter:)
|
||||
else
|
||||
DEFAULT_INVITATION_SUBJECT
|
||||
end
|
||||
|
||||
assign_message_metadata('submitter_invitation', @submitter)
|
||||
|
||||
reply_to = build_submitter_reply_to(@submitter)
|
||||
|
||||
subject =
|
||||
if @email_config || @subject
|
||||
ReplaceEmailVariables.call(@subject || @email_config.value['subject'], submitter:)
|
||||
elsif @submitter.with_signature_fields?
|
||||
I18n.t(:you_are_invited_to_sign_a_document)
|
||||
else
|
||||
I18n.t(:you_are_invited_to_submit_a_form)
|
||||
end
|
||||
|
||||
mail(
|
||||
to: @submitter.friendly_name,
|
||||
from: from_address_for_submitter(submitter),
|
||||
@@ -64,15 +64,12 @@ class SubmitterMailer < ApplicationMailer
|
||||
@body = @submitter.template.preferences['completed_notification_email_body'].presence
|
||||
@body ||= @email_config.value['body'] if @email_config
|
||||
|
||||
subject =
|
||||
if @subject.present?
|
||||
ReplaceEmailVariables.call(@subject, submitter:)
|
||||
else
|
||||
build_completed_subject(submitter)
|
||||
end
|
||||
|
||||
assign_message_metadata('submitter_completed', @submitter)
|
||||
|
||||
subject =
|
||||
ReplaceEmailVariables.call(@subject.presence || I18n.t(:template_name_has_been_completed_by_submitters),
|
||||
submitter:)
|
||||
|
||||
mail(from: from_address_for_submitter(submitter),
|
||||
to: to || (user.role == 'integration' ? user.friendly_name.sub(/\+\w+@/, '@') : user.friendly_name),
|
||||
subject:)
|
||||
@@ -116,17 +113,16 @@ class SubmitterMailer < ApplicationMailer
|
||||
@body = @submitter.template.preferences['documents_copy_email_body'].presence
|
||||
@body ||= @email_config.value['body'] if @email_config
|
||||
|
||||
assign_message_metadata('submitter_documents_copy', @submitter)
|
||||
reply_to = build_submitter_reply_to(submitter)
|
||||
|
||||
subject =
|
||||
if @subject.present?
|
||||
ReplaceEmailVariables.call(@subject, submitter:)
|
||||
else
|
||||
'Your document copy'
|
||||
I18n.t(:your_document_copy)
|
||||
end
|
||||
|
||||
assign_message_metadata('submitter_documents_copy', @submitter)
|
||||
|
||||
reply_to = build_submitter_reply_to(submitter)
|
||||
|
||||
mail(from: from_address_for_submitter(submitter),
|
||||
to: to || @submitter.friendly_name,
|
||||
reply_to:,
|
||||
@@ -145,12 +141,6 @@ class SubmitterMailer < ApplicationMailer
|
||||
reply_to
|
||||
end
|
||||
|
||||
def build_completed_subject(submitter)
|
||||
submitters = submitter.submission.submitters.order(:completed_at)
|
||||
.map { |e| e.name || e.email || e.phone }.join(', ')
|
||||
%(#{submitter.submission.template.name} has been completed by #{submitters})
|
||||
end
|
||||
|
||||
def add_completed_email_attachments!(submitter, with_audit_log: true, with_documents: true)
|
||||
documents = with_documents ? Submitters.select_attachments_for_download(submitter) : []
|
||||
|
||||
|
||||
@@ -43,29 +43,23 @@ class AccountConfig < ApplicationRecord
|
||||
COMBINE_PDF_RESULT_KEY = 'combine_pdf_result_key'
|
||||
|
||||
DEFAULT_VALUES = {
|
||||
SUBMITTER_INVITATION_EMAIL_KEY => {
|
||||
'subject' => 'You are invited to submit a form',
|
||||
'body' => "Hi there,\n\n" \
|
||||
"You have been invited to submit the \"{{template.name}}\" form.\n\n" \
|
||||
"{{submitter.link}}\n\n" \
|
||||
"Please contact us by replying to this email if you didn't request this.\n\n" \
|
||||
"Thanks,\n" \
|
||||
'{{account.name}}'
|
||||
SUBMITTER_INVITATION_EMAIL_KEY => lambda {
|
||||
{
|
||||
'subject' => I18n.t(:you_are_invited_to_sign_a_document),
|
||||
'body' => I18n.t(:submitter_invitation_email_sign_body)
|
||||
}
|
||||
},
|
||||
SUBMITTER_COMPLETED_EMAIL_KEY => {
|
||||
'subject' => '{{template.name}} has been completed by {{submission.submitters}}',
|
||||
'body' => "Hi,\n\n" \
|
||||
"\"{{template.name}}\" form has been completed by {{submission.submitters}}\n\n" \
|
||||
'{{submission.link}}'
|
||||
SUBMITTER_COMPLETED_EMAIL_KEY => lambda {
|
||||
{
|
||||
'subject' => I18n.t(:template_name_has_been_completed_by_submitters),
|
||||
'body' => I18n.t(:submitter_completed_email_body)
|
||||
}
|
||||
},
|
||||
SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY => {
|
||||
'subject' => 'Your document copy',
|
||||
'body' => "Hi there,\n\n" \
|
||||
"Please check the copy of your \"{{template.name}}\" submission in the email attachments.\n" \
|
||||
"Alternatively, you can download your copy using:\n\n" \
|
||||
"{{documents.link}}\n\n" \
|
||||
"Thanks,\n" \
|
||||
'{{account.name}}'
|
||||
SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY => lambda {
|
||||
{
|
||||
'subject' => I18n.t(:your_document_copy),
|
||||
'body' => I18n.t(:submitter_documents_copy_email_body)
|
||||
}
|
||||
}
|
||||
}.freeze
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class="form-control">
|
||||
<div class="flex items-center">
|
||||
<%= ff.label :body, t('body'), class: 'label' %>
|
||||
<span class="tooltip" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES.dig(AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY, 'body').scan(/{{.*?}}/).join(', ') %>">
|
||||
<span class="tooltip" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES[AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY].call['body'].scan(/{.*?}/).join(', ') %>">
|
||||
<%= svg_icon('info_circle', class: 'w-4 h-4') %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class="form-control">
|
||||
<div class="flex items-center">
|
||||
<%= ff.label :body, t('body'), class: 'label' %>
|
||||
<span class="tooltip" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES.dig(AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY, 'body').scan(/{{.*?}}/).join(', ') %>">
|
||||
<span class="tooltip" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES[AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY].call['body'].scan(/{.*?}/).join(', ') %>">
|
||||
<%= svg_icon('info_circle', class: 'w-4 h-4') %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<div class="form-control">
|
||||
<div class="flex items-center">
|
||||
<%= ff.label :subject, t('subject'), class: 'label' %>
|
||||
<span class="tooltip" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES.dig(AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY, 'subject').scan(/{{.*?}}/).join(', ') %>">
|
||||
<span class="tooltip" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES[AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY].call['subject'].scan(/{.*?}/).join(', ') %>">
|
||||
<%= svg_icon('info_circle', class: 'w-4 h-4') %>
|
||||
</span>
|
||||
</div>
|
||||
@@ -21,7 +21,7 @@
|
||||
<div class="form-control">
|
||||
<div class="flex items-center">
|
||||
<%= ff.label :body, t('body'), class: 'label' %>
|
||||
<span class="tooltip" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES.dig(AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY, 'body').scan(/{{.*?}}/).join(', ') %>">
|
||||
<span class="tooltip" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES[AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY].call['body'].scan(/{.*?}/).join(', ') %>">
|
||||
<%= svg_icon('info_circle', class: 'w-4 h-4') %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<div class="form-control">
|
||||
<div class="flex items-center">
|
||||
<%= f.label :message, t('body'), class: 'label' %>
|
||||
<span class="tooltip tooltip-right" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES.dig(AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY, 'body').scan(/{{.*?}}/).join(', ') %>">
|
||||
<span class="tooltip tooltip-right" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES[AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY].call['body'].scan(/{.*?}/).join(', ') %>">
|
||||
<%= svg_icon('info_circle', class: 'w-4 h-4') %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<% if @body.present? %>
|
||||
<%= render 'custom_content', content: @body, submitter: @submitter %>
|
||||
<% else %>
|
||||
<p>Hi there,</p>
|
||||
<p>"<%= @submitter.submission.template.name %>" form has been completed by <%= @submitter.submission.submitters.order(:completed_at).map { |e| e.name || e.email || e.phone }.join(', ') %>.</p>
|
||||
<p><%= link_to 'View Submission', submission_url(@submitter.submission) %></p>
|
||||
<p><%= t('hi_there') %>,</p>
|
||||
<p><%= I18n.t(:name_has_been_completed_by_submitters, name: @submitter.submission.template.name, submitters: @submitter.submission.submitters.order(:completed_at).map { |e| e.name || e.email || e.phone }.join(', ')) %></p>
|
||||
<p><%= link_to submission_url(@submitter.submission), submission_url(@submitter.submission) %></p>
|
||||
<% end %>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<p><%= t('hi_there') %>,</p>
|
||||
<p><%= t('name_declined_by_submitter_with_the_following_reason', name: @submitter.submission.template.name, submitter: @submitter.name || @submitter.email || @submitter.phone) %></p>
|
||||
<%= simple_format(h(@submitter.submission_events.find_by(event_type: :decline_form).data['reason'])) %>
|
||||
<p><%= link_to t('view'), submission_url(@submitter.submission) %></p>
|
||||
<p><%= link_to submission_url(@submitter.submission), submission_url(@submitter.submission) %></p>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<% if @body.present? %>
|
||||
<%= render 'custom_content', content: @body, submitter: @submitter, sig: @sig %>
|
||||
<% else %>
|
||||
<p>Hi there,</p>
|
||||
<p>Please check the copy of your "<%= @submitter.submission.template.name %>" submission in the email attachments.</p>
|
||||
<p>Alternatively, you can review and download your copy using:</p>
|
||||
<p><%= t('hi_there') %>,</p>
|
||||
<p><%= t('please_check_the_copy_of_your_name_in_the_email_attachments', name: @submitter.submission.template.name) %>
|
||||
<p><%= t('alternatively_you_can_review_and_download_your_copy_using_the_link_below') %></p>
|
||||
<p>
|
||||
<%= link_to @submitter.template.name, submissions_preview_url(@submitter.submission.slug, { sig: @sig }.compact) %>
|
||||
</p>
|
||||
<p>
|
||||
Thanks,<br><%= @current_account.name %>
|
||||
<%= t('thanks') %>,<br><%= @current_account.name %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
<p><%= link_to nil, submit_form_url(slug: @submitter.slug, t: SubmissionEvents.build_tracking_param(@submitter, 'click_email')) %></p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p>Hi there,</p>
|
||||
<p>You have been invited to submit the "<%= @submitter.submission.template.name %>" form.</p>
|
||||
<p><%= link_to 'Submit Form', submit_form_url(slug: @submitter.slug, t: SubmissionEvents.build_tracking_param(@submitter, 'click_email')) %></p>
|
||||
<p>Please contact us by replying to this email if you didn't request this.</p>
|
||||
<p><%= t('hi_there') %>,</p>
|
||||
<p><%= I18n.t(@submitter.with_signature_fields? ? :you_have_been_invited_to_sign_the_name : :you_have_been_invited_to_submit_the_name_form, name: @submitter.submission.template.name) %></p>
|
||||
<p><%= link_to I18n.t(@submitter.with_signature_fields? ? :review_and_sign : :review_and_submit), submit_form_url(slug: @submitter.slug, t: SubmissionEvents.build_tracking_param(@submitter, 'click_email')) %></p>
|
||||
<p><%= t('please_contact_us_by_replying_to_this_email_if_you_didn_t_request_this') %></p>
|
||||
<p>
|
||||
Thanks,<br><%= @current_account.name %>
|
||||
<%= t('thanks') %>,<br><%= @current_account.name %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<div class="form-control">
|
||||
<div class="flex items-center">
|
||||
<%= ff.label :request_email_body, t('email_body'), class: 'label' %>
|
||||
<span class="tooltip tooltip-right" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES.dig(AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY, 'body').scan(/{{.*?}}/).join(', ') %>">
|
||||
<span class="tooltip tooltip-right" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES[AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY].call['body'].scan(/{.*?}/).join(', ') %>">
|
||||
<%= svg_icon('info_circle', class: 'w-4 h-4') %>
|
||||
</span>
|
||||
</div>
|
||||
@@ -125,7 +125,7 @@
|
||||
<div class="form-control">
|
||||
<div class="flex items-center">
|
||||
<%= ff.label :documents_copy_email_body, t('email_body'), class: 'label' %>
|
||||
<span class="tooltip tooltip-right" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES.dig(AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY, 'body').scan(/{{.*?}}/).join(', ') %>">
|
||||
<span class="tooltip tooltip-right" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES[AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY].call['body'].scan(/{.*?}/).join(', ') %>">
|
||||
<%= svg_icon('info_circle', class: 'w-4 h-4') %>
|
||||
</span>
|
||||
</div>
|
||||
@@ -172,7 +172,7 @@
|
||||
<div class="form-control">
|
||||
<div class="flex items-center">
|
||||
<%= ff.label :completed_notification_email_body, t('email_body'), class: 'label' %>
|
||||
<span class="tooltip tooltip-right" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES.dig(AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY, 'body').scan(/{{.*?}}/).join(', ') %>">
|
||||
<span class="tooltip tooltip-right" data-tip="<%= t('use_following_placeholders_text_') %> <%= AccountConfig::DEFAULT_VALUES[AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY].call['body'].scan(/{.*?}/).join(', ') %>">
|
||||
<%= svg_icon('info_circle', class: 'w-4 h-4') %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
+45
-1
@@ -18,6 +18,50 @@ en: &en
|
||||
language_nl: Nederlands
|
||||
language_ar: العربية
|
||||
language_ko: 한국어
|
||||
hi_there: Hi there
|
||||
thanks: Thanks
|
||||
you_have_been_invited_to_submit_the_name_form: 'You have been invited to submit the "%{name}" form.'
|
||||
you_have_been_invited_to_sign_the_name: 'You have been invited to sign the "%{name}".'
|
||||
alternatively_you_can_review_and_download_your_copy_using_the_link_below: "Alternatively, you can review and download your copy using the link below:"
|
||||
please_check_the_copy_of_your_name_in_the_email_attachments: 'Please check the copy of your "%{name}" in the email attachments.'
|
||||
review_and_sign: Review and Sign
|
||||
review_and_submit: Review and Submit
|
||||
please_contact_us_by_replying_to_this_email_if_you_didn_t_request_this: "Please contact us by replying to this email if you didn't request this."
|
||||
submitter_invitation_sms_body_sign: '{account.name} has invited you to sign a document: {submitter.link}'
|
||||
verification_code_sms_body: 'Verification code: {code}'
|
||||
you_are_invited_to_submit_a_form: 'You are invited to submit a form'
|
||||
you_are_invited_to_sign_a_document: 'You are invited to sign a document'
|
||||
you_are_invited_to_sign_documents: 'You are invited to sign documents'
|
||||
your_document_copy: 'Your document copy'
|
||||
name_has_been_completed_by_submitters: '%{name} has been completed by %{submitters}.'
|
||||
template_name_has_been_completed_by_submitters: '{template.name} has been completed by {submission.submitters}'
|
||||
submitter_invitation_email_sign_body: |
|
||||
Hi there,
|
||||
|
||||
You have been invited to sign the "{template.name}".
|
||||
|
||||
[Review and Sign]({submitter.link})
|
||||
|
||||
Please contact us by replying to this email if you didn't request this.
|
||||
|
||||
Thanks,
|
||||
{account.name}
|
||||
submitter_completed_email_body: |
|
||||
Hi,
|
||||
|
||||
"{template.name}" has been completed by {submission.submitters}
|
||||
|
||||
{submission.link}
|
||||
submitter_documents_copy_email_body: |
|
||||
Hi there,
|
||||
|
||||
Please check the copy of your "{template.name}" in the email attachments.
|
||||
Alternatively, you can review and download your copy using the link below:
|
||||
|
||||
[{template.name}]({documents.link})
|
||||
|
||||
Thanks,
|
||||
{account.name}
|
||||
view: View
|
||||
hi_there: Hi there
|
||||
email: Email
|
||||
@@ -323,7 +367,7 @@ en: &en
|
||||
draw_signature: Draw Signature
|
||||
clear: Clear
|
||||
signature_uploaded: Signature Uploaded
|
||||
submission_deletion_is_irreversible_and_will_permanently_remove_all_associated_signed_documents_with_it_are_you_sure_:
|
||||
submission_deletion_is_irreversible_and_will_permanently_remove_all_associated_signed_documents_with_it_are_you_sure_: 'Submission deletion is irreversible and will permanently remove all associated signed documents with it. Are you sure?'
|
||||
return_back_to_your_desktop_device_to_complete_the_form_or_continue_on_mobile_html: 'Return back to your desktop device to complete the form or <a class="link" href="%{link}">continue on mobile</a>'
|
||||
template_deletion_is_irreversible_and_will_permanently_remove_all_associated_signed_documents_with_it_are_you_sure_: Template deletion is irreversible and will permanently remove all associated signed documents with it. Are you sure?
|
||||
rename_folder: Rename Folder
|
||||
|
||||
@@ -18,7 +18,7 @@ module AccountConfigs
|
||||
|
||||
def find_or_initialize_for_key(account, key)
|
||||
find_for_account(account, key) ||
|
||||
account.account_configs.new(key:, value: AccountConfig::DEFAULT_VALUES[key])
|
||||
account.account_configs.new(key:, value: AccountConfig::DEFAULT_VALUES[key]&.call)
|
||||
end
|
||||
|
||||
def find_for_account(account, key)
|
||||
|
||||
Reference in New Issue
Block a user