From 6dbc838bae07146e341e1b1e486f46528d05064b Mon Sep 17 00:00:00 2001 From: Ridhwana Date: Fri, 17 Apr 2020 21:35:35 +0200 Subject: [PATCH] [deploy] Update our mailers to be generalized (#7359) * feat: make the from in the email to be dynamic * feat: hardcoded mailer dev.to * feat: oops hardcoded email addresses in the terms * chore: remove some whitespace * update editor guide * feat: new reply email * feat: new message mailer * feat: new follower email * feat: capitalize the button * feat: rename the link * feat: capitalize the button * feat: generalize the urls * feat: generalise the url * feat: dynamic DEV * feat: update the specs * feat: DEV digest generalisation part 1 * fix: the method is accessed by tag_url and so the default parameter needs to be set at this level and not at self.tag * fix: use the tag model instance instead of passing through just the tag name (so that we can use tag_url) * chore: make code climate happy * chore: more robocop * feat: add a default url back for self.tag * test: fix the feedback helper spec * fix: spec to be general * fix: oops :( * refactor: user_settings_path * chore: use code_of_conduct_path * chore: robocop * chore: use connect path * chore; use the notifications symbol * chore: misc path * feat: simplify url * feat/fix: change the order of the helpers and use user_url * chore: user_url * capitalise * chore: update article path --- .../initializeCommentsPage.js.erb | 2 - app/helpers/application_helper.rb | 2 +- app/helpers/feedback_messages_helper.rb | 2 +- app/labor/assign_tag_moderator.rb | 2 +- app/mailers/application_mailer.rb | 6 ++- app/mailers/digest_mailer.rb | 33 ++++++++------- app/mailers/notify_mailer.rb | 14 +++---- app/views/chat_channels/index.html.erb | 2 +- .../invalid_token.html.erb | 2 +- app/views/layouts/mailer.html.erb | 4 +- .../digest_mailer/digest_email.html.erb | 10 ++--- .../notify_mailer/new_follower_email.html.erb | 6 +-- .../notify_mailer/new_mention_email.html.erb | 4 +- .../notify_mailer/new_message_email.html.erb | 6 +-- .../notify_mailer/new_message_email.text.erb | 2 +- .../notify_mailer/new_reply_email.html.erb | 6 +-- .../notify_mailer/new_reply_email.text.erb | 2 +- .../tag_moderator_confirmation_email.html.erb | 6 +-- .../notify_mailer/trusted_role_email.html.erb | 6 +-- .../notify_mailer/trusted_role_email.text.erb | 2 +- .../unread_notifications_email.html.erb | 2 +- .../unread_notifications_email.text.erb | 2 +- .../video_upload_complete_email.html.erb | 2 +- .../video_upload_complete_email.text.erb | 2 +- app/views/pages/_terms_text.html.erb | 4 +- app/views/pages/code_of_conduct.html.erb | 4 +- app/views/pages/editor_guide.html.erb | 2 +- spec/helpers/feedback_messages_helper_spec.rb | 2 +- spec/mailers/digest_mailer_spec.rb | 2 +- spec/mailers/notify_mailer_spec.rb | 42 +++++++++---------- .../mailers/previews/notify_mailer_preview.rb | 4 +- .../send_email_notification_worker_spec.rb | 2 +- 32 files changed, 96 insertions(+), 93 deletions(-) diff --git a/app/assets/javascripts/initializers/initializeCommentsPage.js.erb b/app/assets/javascripts/initializers/initializeCommentsPage.js.erb index 24ec30105..fcd604344 100644 --- a/app/assets/javascripts/initializers/initializeCommentsPage.js.erb +++ b/app/assets/javascripts/initializers/initializeCommentsPage.js.erb @@ -1,5 +1,3 @@ - - function initializeCommentsPage() { if (document.getElementById('comments-container')) { toggleCodeOfConduct(); diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4328f02ce..d88301e16 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -194,7 +194,7 @@ module ApplicationHelper URL.reaction(reaction) end - def tag_url(tag, page) + def tag_url(tag, page = 1) URL.tag(tag, page) end diff --git a/app/helpers/feedback_messages_helper.rb b/app/helpers/feedback_messages_helper.rb index a08ae5332..817ff6dae 100644 --- a/app/helpers/feedback_messages_helper.rb +++ b/app/helpers/feedback_messages_helper.rb @@ -40,6 +40,6 @@ module FeedbackMessagesHelper DEV Team HEREDOC - { subject: "Courtesy Notice from DEV", body: body }.freeze + { subject: "Courtesy Notice from #{ApplicationConfig['COMMUNITY_NAME']}", body: body }.freeze end end diff --git a/app/labor/assign_tag_moderator.rb b/app/labor/assign_tag_moderator.rb index 832bf34ee..7908cb27a 100644 --- a/app/labor/assign_tag_moderator.rb +++ b/app/labor/assign_tag_moderator.rb @@ -17,7 +17,7 @@ module AssignTagModerator add_tag_mod_role(user, tag) add_trusted_role(user) add_to_chat_channels(user, tag) - NotifyMailer.tag_moderator_confirmation_email(user, tag.name).deliver unless tag.name == "go" + NotifyMailer.tag_moderator_confirmation_email(user, tag).deliver unless tag.name == "go" end end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index b9f17a5f9..2d9d847c0 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,9 +1,13 @@ class ApplicationMailer < ActionMailer::Base layout "mailer" + # the order of importing the helpers here is important + # we want the application helpers to override the Rails route helpers should there be a name conflict + # an example is the user_url + helper Rails.application.routes.url_helpers helper ApplicationHelper default( - from: -> { "DEV Community <#{SiteConfig.default_site_email}>" }, + from: -> { "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.default_site_email}>" }, template_path: ->(mailer) { "mailers/#{mailer.class.name.underscore}" }, ) diff --git a/app/mailers/digest_mailer.rb b/app/mailers/digest_mailer.rb index 420a9662d..c4adf0bdc 100644 --- a/app/mailers/digest_mailer.rb +++ b/app/mailers/digest_mailer.rb @@ -1,5 +1,5 @@ class DigestMailer < ApplicationMailer - default from: -> { "DEV Digest <#{SiteConfig.default_site_email}>" } + default from: -> { "#{ApplicationConfig['COMMUNITY_NAME']} Digest <#{SiteConfig.default_site_email}>" } def digest_email(user, articles) @user = user @@ -25,26 +25,27 @@ class DigestMailer < ApplicationMailer end def email_end_phrase + community_name = ApplicationConfig["COMMUNITY_NAME"] # "more trending DEV posts" won the previous split test # Included more often as per explore-exploit algorithm [ - "more trending DEV posts", - "more trending DEV posts", - "more trending DEV posts", - "more trending DEV posts", - "more trending DEV posts", - "more trending DEV posts", - "more trending DEV posts", - "more trending DEV posts", - "more trending DEV posts", + "more trending #{community_name} posts", + "more trending #{community_name} posts", + "more trending #{community_name} posts", + "more trending #{community_name} posts", + "more trending #{community_name} posts", + "more trending #{community_name} posts", + "more trending #{community_name} posts", + "more trending #{community_name} posts", + "more trending #{community_name} posts", "other posts you might like", - "other DEV posts you might like", - "other trending DEV posts", - "other top DEV posts", - "more top DEV posts", + "other #{community_name} posts you might like", + "other trending #{community_name} posts", + "other top #{community_name} posts", + "more top #{community_name} posts", "more top reads from the community", - "more top DEV posts based on your interests", - "more trending DEV posts picked for you", + "more top #{community_name} posts based on your interests", + "more trending #{community_name} posts picked for you", ].sample end end diff --git a/app/mailers/notify_mailer.rb b/app/mailers/notify_mailer.rb index 4ec716140..343fdfbd9 100644 --- a/app/mailers/notify_mailer.rb +++ b/app/mailers/notify_mailer.rb @@ -1,6 +1,6 @@ class NotifyMailer < ApplicationMailer SUBJECTS = { - new_follower_email: "just followed you on dev.to".freeze + new_follower_email: "just followed you on #{ApplicationConfig['COMMUNITY_NAME']}".freeze }.freeze def new_reply_email(comment) @@ -40,7 +40,7 @@ class NotifyMailer < ApplicationMailer @unread_notifications_count = NotificationCounter.new(@user).unread_notification_count @unsubscribe = generate_unsubscribe_token(@user.id, :email_unread_notifications) - subject = "๐Ÿ”ฅ You have #{@unread_notifications_count} unread notifications on dev.to" + subject = "๐Ÿ”ฅ You have #{@unread_notifications_count} unread notifications on #{ApplicationConfig['COMMUNITY_NAME']}" mail(to: @user.email, subject: subject) end @@ -94,14 +94,14 @@ class NotifyMailer < ApplicationMailer def account_deleted_email(user) @name = user.name - subject = "dev.to - Account Deletion Confirmation" + subject = "#{ApplicationConfig['COMMUNITY_NAME']} - Account Deletion Confirmation" mail(to: user.email, subject: subject) end def account_deletion_requested_email(user, token) @name = user.name @token = token - subject = "dev.to - Account Deletion Requested" + subject = "#{ApplicationConfig['COMMUNITY_NAME']} - Account Deletion Requested" mail(to: user.email, subject: subject) end @@ -112,10 +112,10 @@ class NotifyMailer < ApplicationMailer mail(to: @user.email, subject: "The export of your content is ready") end - def tag_moderator_confirmation_email(user, tag_name) - @tag_name = tag_name + def tag_moderator_confirmation_email(user, tag) + @tag = tag @user = user - subject = "Congrats! You're the moderator for ##{tag_name}" + subject = "Congrats! You're the moderator for ##{@tag.name}" mail(to: @user.email, subject: subject) end diff --git a/app/views/chat_channels/index.html.erb b/app/views/chat_channels/index.html.erb index 4bb695654..478347873 100644 --- a/app/views/chat_channels/index.html.erb +++ b/app/views/chat_channels/index.html.erb @@ -1,6 +1,6 @@ <% title("#{community_name} Connect ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ’ฌ๐Ÿ‘จโ€๐Ÿ’ป") %> <%= content_for :page_meta do %> - " /> + <% end %> <%= csrf_meta_tags %> diff --git a/app/views/email_subscriptions/invalid_token.html.erb b/app/views/email_subscriptions/invalid_token.html.erb index 734674c36..8b06443d3 100644 --- a/app/views/email_subscriptions/invalid_token.html.erb +++ b/app/views/email_subscriptions/invalid_token.html.erb @@ -6,7 +6,7 @@
Please - sign-in + sign-in to manage your email preferences.
diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index 44e8734e2..eee0c2acc 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -18,10 +18,10 @@
<% if @unsubscribe %> <%= link_to "Unsubscribe", email_subscriptions_unsubscribe_url(ut: @unsubscribe), style: "color:#7d7d7d" %> | - Adjust your email settings + Adjust your email settings <% else %> Don't want to get emails like this? Adjust your email settings at - dev.to/settings/notifications + <%= app_url(user_settings_path(:notifications)) %> <% end %>
diff --git a/app/views/mailers/digest_mailer/digest_email.html.erb b/app/views/mailers/digest_mailer/digest_email.html.erb index b7838bea0..8b4a2932b 100644 --- a/app/views/mailers/digest_mailer/digest_email.html.erb +++ b/app/views/mailers/digest_mailer/digest_email.html.erb @@ -5,7 +5,7 @@