From e72073ca6bd0d7513733d964512aa54db66a4fbd Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 27 Sep 2022 08:19:13 -0500 Subject: [PATCH] emails: update email templates. * Add header with the Danbooru name and logo. * Add footer with links to the site, the privacy policy, and the contact page. * Add "You received this email because of X" messages to remind users why they received the email. * Add basic CSS to make the design match the site. --- app/mailers/user_mailer.rb | 3 +- app/views/layouts/user_mailer.html.erb | 55 +++++++++++++++++++ app/views/user_mailer/dmail_notice.html.erb | 25 ++++++--- .../email_change_confirmation.html.erb | 29 ++++------ app/views/user_mailer/password_reset.html.erb | 30 +++++----- app/views/user_mailer/welcome_user.html.erb | 31 +++++------ 6 files changed, 114 insertions(+), 59 deletions(-) create mode 100644 app/views/layouts/user_mailer.html.erb diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index b97b0518e..00b41ed91 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -4,7 +4,8 @@ class UserMailer < ApplicationMailer # The email sent when a user receives a DMail. def dmail_notice(dmail) @dmail = dmail - mail(dmail.to, require_verified_email: true, subject: "#{Danbooru.config.app_name} - Message received from #{dmail.from.name}") + @user = dmail.to + mail(@user, require_verified_email: true, subject: "#{Danbooru.config.app_name}: #{dmail.from.name} sent you a message") end # The email sent when a user requests a password reset. diff --git a/app/views/layouts/user_mailer.html.erb b/app/views/layouts/user_mailer.html.erb new file mode 100644 index 000000000..87940b7bf --- /dev/null +++ b/app/views/layouts/user_mailer.html.erb @@ -0,0 +1,55 @@ + + + + + + +

+ <%= link_to image_tag(image_url("/images/danbooru-logo-96x96.png", host: root_url), width: 36, height: 36, style: "vertical-align: middle"), root_url %> + <%= link_to Danbooru.config.canonical_app_name, root_url %> +

+ + <%= yield %> + +
+
+

+ <%= link_to image_tag(image_url("/images/danbooru-logo-96x96.png", host: root_url), width: 16, height: 16, style: "vertical-align: middle"), root_url %> + <%= link_to Danbooru.config.canonical_app_name, root_url %> / + <%= link_to "Privacy", privacy_policy_url %> / + <%= link_to "Contact", contact_url %> + <% if content_for(:footer_links).present? %> + <%= yield :footer_links %> + <% end %> +

+
+ + diff --git a/app/views/user_mailer/dmail_notice.html.erb b/app/views/user_mailer/dmail_notice.html.erb index 2776e795f..2d0711566 100644 --- a/app/views/user_mailer/dmail_notice.html.erb +++ b/app/views/user_mailer/dmail_notice.html.erb @@ -1,12 +1,21 @@ - - - -

<%= @dmail.from.name %> said:

+

Hi <%= link_to_user @user %>,

+ +

<%= link_to_user @dmail.from %> sent you a message on <%= link_to Danbooru.config.canonical_app_name, root_url %>:

+ +
+ <%= @dmail.title %> -
<%= format_text(@dmail.body, base_url: root_url) %>
-

<%= link_to "View message", dmail_url(@dmail) %> | <%= link_to "Disable notifications", disable_email_notifications_url(@dmail.to) %>

- - +<%= link_to "Reply", new_dmail_url(respond_to_id: @dmail) %> | +<%= link_to "View message", dmail_url(@dmail) %> + +

+ You received this email because you chose to receive notifications whenever someone sends you a message on <%= Danbooru.config.canonical_app_name %>. + <%= link_to "Click here", disable_email_notifications_url(@user) %> to unsubscribe from these emails. +

+ +<% content_for(:footer_links) do %> + / <%= link_to "Unsubscribe", disable_email_notifications_url(@user) %> +<% end %> diff --git a/app/views/user_mailer/email_change_confirmation.html.erb b/app/views/user_mailer/email_change_confirmation.html.erb index 148d89ef2..6391d5762 100644 --- a/app/views/user_mailer/email_change_confirmation.html.erb +++ b/app/views/user_mailer/email_change_confirmation.html.erb @@ -1,20 +1,15 @@ - - - -

Hi <%= @user.name %>,

+

Hi <%= link_to_user @user %>,

-

- You recently changed your email address on <%= Danbooru.config.app_name %>. - Click the link below to verify your new email address. -

+

+ You changed your email address on <%= link_to Danbooru.config.canonical_app_name, root_url %>. + Click the link below to verify your new email address: +

-

- <%= link_to "Verify email address", email_verification_url(@user) %> -

+

+ <%= link_to "Verify email address", email_verification_url(@user) %> +

-

- If you did not recently change your email address on <%= Danbooru.config.app_name %>, - you may delete and ignore this email. -

- - +

+ You received this email because someone changed their email to this address on <%= link_to Danbooru.config.canonical_app_name, root_url %>. If this + wasn't you, you may ignore this email. +

diff --git a/app/views/user_mailer/password_reset.html.erb b/app/views/user_mailer/password_reset.html.erb index a91585375..68ea5b6d7 100644 --- a/app/views/user_mailer/password_reset.html.erb +++ b/app/views/user_mailer/password_reset.html.erb @@ -1,19 +1,15 @@ - - - -

- You recently requested your <%= Danbooru.config.app_name %> password to be reset. - Click the link below to login to <%= Danbooru.config.app_name %> and reset your password. -

+

Hi <%= link_to_user @user %>,

-

- <%= link_to "Reset password", edit_user_password_url(@user, signed_user_id: Danbooru::MessageVerifier.new(:login).generate(@user.id, expires_in: 30.minutes)) %> -

+

+ You requested your <%= link_to Danbooru.config.canonical_app_name, root_url %> password to be reset. + Click the link below to reset your password: +

-

- If you did not request for your <%= Danbooru.config.app_name %> password to - be reset, please ignore this email or reply to let us know. This link - will only be valid for the next 30 minutes. -

- - +

+ <%= link_to "Reset password", edit_user_password_url(@user, signed_user_id: Danbooru::MessageVerifier.new(:login).generate(@user.id, expires_in: 30.minutes)) %> +

+ +

+ You received this email because someone requested a password reset for your account on <%= link_to Danbooru.config.canonical_app_name, root_url %>.
+ If this wasn't you, you may ignore this email. This link will expire in 30 minutes. +

diff --git a/app/views/user_mailer/welcome_user.html.erb b/app/views/user_mailer/welcome_user.html.erb index bb155bde5..66f86e18b 100644 --- a/app/views/user_mailer/welcome_user.html.erb +++ b/app/views/user_mailer/welcome_user.html.erb @@ -1,19 +1,18 @@ - - - -

Hi <%= @user.name %>,

+

Hi <%= link_to_user @user %>,

-

- Welcome to <%= Danbooru.config.app_name %>! Click the link below to verify your email address. -

+

+ Welcome to <%= link_to Danbooru.config.canonical_app_name, root_url %>! Click the link below to verify your email address: +

-

- <%= link_to "Verify email address", email_verification_url(@user) %> -

+

+ <%= link_to "Verify email address", email_verification_url(@user) %> +

-

- By verifying your email address, you can receive site notifications and you can - recover your account if you ever forget your password. -

- - +

+ You received this email because someone signed up for <%= link_to Danbooru.config.canonical_app_name, root_url %> with your address. + <%= link_to "Click here", disable_email_notifications_url(@user) %> to disable email notifications. +

+ +<% content_for(:footer_links) do %> + / <%= link_to "Unsubscribe", disable_email_notifications_url(@user) %> +<% end %>