From 2c80e9da42a56bf5177b17ef26e3fdd646ab362c Mon Sep 17 00:00:00 2001
From: Mohab Abd El-Dayem
Date: Fri, 1 Nov 2019 15:03:06 +0200
Subject: [PATCH] Make The Default Email An Enviroment Variable. (#4677)
* Make the default email an enviroment variable
* Added spaces in Envfile for readability
---
Envfile | 3 +++
app/controllers/api_secrets_controller.rb | 2 +-
app/controllers/users_controller.rb | 2 +-
app/labor/error_message_cleaner.rb | 2 +-
app/mailers/application_mailer.rb | 2 +-
app/mailers/digest_mailer.rb | 2 +-
app/mailers/pro_membership_mailer.rb | 2 +-
app/models/organization.rb | 4 ++--
app/views/devise/shared/_authorization_error.html.erb | 2 +-
app/views/feedback_messages/index.html.erb | 2 +-
.../mailers/notify_mailer/account_deleted_email.html.erb | 2 +-
.../mailers/notify_mailer/account_deleted_email.text.erb | 2 +-
app/views/moderations/index.html.erb | 6 +++---
app/views/notifications/_notifications_list.html.erb | 2 +-
app/views/notifications/_tagadjustment.html.erb | 2 +-
app/views/pages/contact.html.erb | 2 +-
app/views/pages/swagnets.html.erb | 2 +-
app/views/podcast_episodes/_sidebar.html.erb | 2 +-
app/views/users/_account.html.erb | 2 +-
app/views/users/_publishing_from_rss.html.erb | 2 +-
app/views/users/edit.html.erb | 2 +-
app/views/videos/new.html.erb | 2 +-
spec/mailers/digest_mailer_spec.rb | 2 +-
spec/mailers/pro_membership_mailer_spec.rb | 2 +-
spec/requests/user_settings_spec.rb | 2 +-
25 files changed, 30 insertions(+), 27 deletions(-)
diff --git a/Envfile b/Envfile
index 0e306d2a4..bcddf4ad4 100644
--- a/Envfile
+++ b/Envfile
@@ -21,6 +21,9 @@ variable :LOGO_SVG, :String, default: ""
# Default staff account's id
variable :DEVTO_USER_ID, :Integer, default: 1
+# Default site email
+variable :DEFAULT_SITE_EMAIL, :String, default: "yo@dev.to"
+
# Service timeout length
variable :RACK_TIMEOUT_WAIT_TIMEOUT, :Integer, default: 100_000
variable :RACK_TIMEOUT_SERVICE_TIMEOUT, :Integer, default: 100_000
diff --git a/app/controllers/api_secrets_controller.rb b/app/controllers/api_secrets_controller.rb
index ecddae27f..4f5af78b7 100644
--- a/app/controllers/api_secrets_controller.rb
+++ b/app/controllers/api_secrets_controller.rb
@@ -23,7 +23,7 @@ class ApiSecretsController < ApplicationController
if @secret.destroy
flash[:notice] = "Your API Key has been revoked."
else
- flash[:error] = "An error occurred. Please try again or send an email to: yo@dev.to"
+ flash[:error] = "An error occurred. Please try again or send an email to: #{ApplicationConfig['DEFAULT_SITE_EMAIL']}"
end
redirect_back(fallback_location: root_path)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 0726e37e7..fd15b5697 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -94,7 +94,7 @@ class UsersController < ApplicationController
flash[:settings_notice] = "Your #{provider.capitalize} account was successfully removed."
else
- flash[:error] = "An error occurred. Please try again or send an email to: yo@dev.to"
+ flash[:error] = "An error occurred. Please try again or send an email to: #{ApplicationConfig['DEFAULT_SITE_EMAIL']}"
end
redirect_to "/settings/#{@tab}"
end
diff --git a/app/labor/error_message_cleaner.rb b/app/labor/error_message_cleaner.rb
index 99163c3dd..bcef73b23 100644
--- a/app/labor/error_message_cleaner.rb
+++ b/app/labor/error_message_cleaner.rb
@@ -7,7 +7,7 @@ class ErrorMessageCleaner
def clean
if error_message.include? "expected key while parsing a block mapping at line"
- "There was a problem parsing the front-matter YAML. Perhaps you need to escape a quote or a colon or something. Email yo@dev.to if you are having trouble."
+ "There was a problem parsing the front-matter YAML. Perhaps you need to escape a quote or a colon or something. Email #{ApplicationConfig['DEFAULT_SITE_EMAIL']} if you are having trouble."
else
error_message
end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index fc8da1928..bec34766e 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -1,5 +1,5 @@
class ApplicationMailer < ActionMailer::Base
- default from: "DEV Community "
+ default from: "DEV Community <#{ApplicationConfig['DEFAULT_SITE_EMAIL']}>"
layout "mailer"
default template_path: ->(mailer) { "mailers/#{mailer.class.name.underscore}" }
diff --git a/app/mailers/digest_mailer.rb b/app/mailers/digest_mailer.rb
index ef4f9987f..cfe4cab15 100644
--- a/app/mailers/digest_mailer.rb
+++ b/app/mailers/digest_mailer.rb
@@ -1,5 +1,5 @@
class DigestMailer < ApplicationMailer
- default from: "DEV Digest "
+ default from: "DEV Digest <#{ApplicationConfig['DEFAULT_SITE_EMAIL']}>"
def digest_email(user, articles)
@user = user
diff --git a/app/mailers/pro_membership_mailer.rb b/app/mailers/pro_membership_mailer.rb
index 4a901ee12..b50f24ac9 100644
--- a/app/mailers/pro_membership_mailer.rb
+++ b/app/mailers/pro_membership_mailer.rb
@@ -1,5 +1,5 @@
class ProMembershipMailer < ApplicationMailer
- default from: "DEV Pro Memberships "
+ default from: "DEV Pro Memberships <#{ApplicationConfig['DEFAULT_SITE_EMAIL']}>"
def expiring_membership(pro_membership, expiration_date)
@pro_membership = pro_membership
diff --git a/app/models/organization.rb b/app/models/organization.rb
index de5a3e006..a85cc0914 100644
--- a/app/models/organization.rb
+++ b/app/models/organization.rb
@@ -33,7 +33,7 @@ class Organization < ApplicationRecord
format: { with: /\A[a-zA-Z0-9\-_]+\Z/ },
length: { in: 2..18 },
exclusion: { in: ReservedWords.all,
- message: "%s is a reserved word. Contact yo@dev.to for help registering your organization." }
+ message: "%s is a reserved word. Contact #{ApplicationConfig['DEFAULT_SITE_EMAIL']} for help registering your organization." }
validates :url, url: { allow_blank: true, no_local: true, schemes: %w[https http] }
validates :secret, uniqueness: { allow_blank: true }
validates :location, :email, :company_size, length: { maximum: 64 }
@@ -46,7 +46,7 @@ class Organization < ApplicationRecord
validates :cta_button_text, length: { maximum: 20 }
validates :cta_body_markdown, length: { maximum: 256 }
before_save :remove_at_from_usernames
- after_save :bust_cache
+ after_save :bust_cache
before_save :generate_secret
before_save :update_articles
before_validation :downcase_slug
diff --git a/app/views/devise/shared/_authorization_error.html.erb b/app/views/devise/shared/_authorization_error.html.erb
index df11b1911..2eb1c0773 100644
--- a/app/views/devise/shared/_authorization_error.html.erb
+++ b/app/views/devise/shared/_authorization_error.html.erb
@@ -25,6 +25,6 @@
<%= flash[:alert] %>
<% end %>
- Please try again below, or contact yo@dev.to if this persists.
+ Please try again below, or contact "><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %> if this persists.
<% end %>
diff --git a/app/views/feedback_messages/index.html.erb b/app/views/feedback_messages/index.html.erb
index 71ca4523c..5c0ae5384 100644
--- a/app/views/feedback_messages/index.html.erb
+++ b/app/views/feedback_messages/index.html.erb
@@ -4,7 +4,7 @@
Thank you for your report.
- Questions? Send an email to yo@dev.to
+ Questions? Send an email to "><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>
diff --git a/app/views/mailers/notify_mailer/account_deleted_email.html.erb b/app/views/mailers/notify_mailer/account_deleted_email.html.erb
index d0bb6e1c4..1d82835ce 100644
--- a/app/views/mailers/notify_mailer/account_deleted_email.html.erb
+++ b/app/views/mailers/notify_mailer/account_deleted_email.html.erb
@@ -7,7 +7,7 @@
- Contact us at yo@dev.to if there is anything more we can help with. 😊
+ Contact us at "><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %> if there is anything more we can help with. 😊
diff --git a/app/views/mailers/notify_mailer/account_deleted_email.text.erb b/app/views/mailers/notify_mailer/account_deleted_email.text.erb
index 7f3b3a3a3..456c1891e 100644
--- a/app/views/mailers/notify_mailer/account_deleted_email.text.erb
+++ b/app/views/mailers/notify_mailer/account_deleted_email.text.erb
@@ -1,6 +1,6 @@
Hi <%= @name %>, your account has been successfully deleted.
-Contact us at yo@dev.to if there is anything more we can help with.
+Contact us at <%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %> if there is anything more we can help with.
Thanks,
The DEV Team
diff --git a/app/views/moderations/index.html.erb b/app/views/moderations/index.html.erb
index 44b11fee0..8544a8a40 100644
--- a/app/views/moderations/index.html.erb
+++ b/app/views/moderations/index.html.erb
@@ -111,8 +111,8 @@
<%= HTML_Truncator.truncate(
article.processed_html,
200,
- ellipsis: '').html_safe
- %>
+ ellipsis: '',
+ ).html_safe %>
<% if article.last_buffered.nil? %>
@@ -150,7 +150,7 @@
DEV Mods
We periodically award some DEV members with heightened privileges to help moderate the community.
-
Email yo@dev.to if you'd like to be considered right away.
+
Email "><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %> if you'd like to be considered right away.
<% if !user_signed_in? %>
P.S. You are not currently signed in.
<% end %>
diff --git a/app/views/notifications/_notifications_list.html.erb b/app/views/notifications/_notifications_list.html.erb
index 7924d6196..d8e064588 100644
--- a/app/views/notifications/_notifications_list.html.erb
+++ b/app/views/notifications/_notifications_list.html.erb
@@ -14,7 +14,7 @@
<% end %>
diff --git a/app/views/notifications/_tagadjustment.html.erb b/app/views/notifications/_tagadjustment.html.erb
index bd6b924ad..b46030a40 100644
--- a/app/views/notifications/_tagadjustment.html.erb
+++ b/app/views/notifications/_tagadjustment.html.erb
@@ -20,6 +20,6 @@
Check out
other popular tags which may be more appropriate.
Thanks for being part of DEV! If you feel like this mod action was a mistake, feel free to contact
-
yo@dev.to. 🤗
+
"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>. 🤗
diff --git a/app/views/pages/contact.html.erb b/app/views/pages/contact.html.erb
index 3018893cb..87aac5906 100644
--- a/app/views/pages/contact.html.erb
+++ b/app/views/pages/contact.html.erb
@@ -30,7 +30,7 @@
The Practical Dev would love to hear from you!
- Email: yo@dev.to 😁
+ Email: "><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %> 😁
Twitter: ">@<%= ApplicationConfig["SITE_TWITTER_HANDLE"] %> 👻
diff --git a/app/views/pages/swagnets.html.erb b/app/views/pages/swagnets.html.erb
index bcfe62042..4297a4edb 100644
--- a/app/views/pages/swagnets.html.erb
+++ b/app/views/pages/swagnets.html.erb
@@ -25,7 +25,7 @@
We understand that some of you won't have a device that supports your new Swagnet, but we hope that you have a friend who can enjoy it :)
By the way, you can also buy Swagnets that benefit open-source projects: you can check those out
here.
Comments? Suggestions? Ping us on Twitter or at
- yo@dev.to.
+ "><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>.
diff --git a/app/views/podcast_episodes/_sidebar.html.erb b/app/views/podcast_episodes/_sidebar.html.erb
index 9b900a0a2..15123b455 100644
--- a/app/views/podcast_episodes/_sidebar.html.erb
+++ b/app/views/podcast_episodes/_sidebar.html.erb
@@ -28,7 +28,7 @@
<% end %>
- If you know of a great dev podcast that should be added to this list, contact yo@dev.to
+ If you know of a great dev podcast that should be added to this list, contact "><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>
<% elsif @podcast %>
diff --git a/app/views/users/_account.html.erb b/app/views/users/_account.html.erb
index c48509668..09b532e6c 100644
--- a/app/views/users/_account.html.erb
+++ b/app/views/users/_account.html.erb
@@ -148,7 +148,7 @@
Request Account Deletion
-
+ ?subject=Request Account Deletion&body=<%= @email_body %>">
Click this link to request account deletion via email.
This includes all articles, comments, reactions, etc. as well as any personal information you have.
diff --git a/app/views/users/_publishing_from_rss.html.erb b/app/views/users/_publishing_from_rss.html.erb
index 663e97d82..9f9a28a51 100644
--- a/app/views/users/_publishing_from_rss.html.erb
+++ b/app/views/users/_publishing_from_rss.html.erb
@@ -26,7 +26,7 @@
Your feed will be fetched every time you submit this form and updates will be automatically fetched periodically thereafter. Contact
- yo@dev.to if you encounter issues.
+ "><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %> if you encounter issues.
FYI: Medium RSS feed URLs are https://medium.com/feed/@your_username
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
index ca3be3563..c070ae900 100644
--- a/app/views/users/edit.html.erb
+++ b/app/views/users/edit.html.erb
@@ -15,7 +15,7 @@
<% if params[:state] == "previous-registration" %>
<% end %>
diff --git a/app/views/videos/new.html.erb b/app/views/videos/new.html.erb
index 42da9f0a6..cfb95aa4e 100644
--- a/app/views/videos/new.html.erb
+++ b/app/views/videos/new.html.erb
@@ -33,7 +33,7 @@
<% end %>
diff --git a/spec/mailers/digest_mailer_spec.rb b/spec/mailers/digest_mailer_spec.rb
index c43114e60..fa2d1dff8 100644
--- a/spec/mailers/digest_mailer_spec.rb
+++ b/spec/mailers/digest_mailer_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe DigestMailer, type: :mailer do
expect(email.subject).not_to be_nil
expect(email.to).to eq([user.email])
- expect(email.from).to eq(["yo@dev.to"])
+ expect(email.from).to eq([ApplicationConfig["DEFAULT_SITE_EMAIL"]])
end
it "includes the tracking pixel" do
diff --git a/spec/mailers/pro_membership_mailer_spec.rb b/spec/mailers/pro_membership_mailer_spec.rb
index 2a0032d81..e1e8a3c02 100644
--- a/spec/mailers/pro_membership_mailer_spec.rb
+++ b/spec/mailers/pro_membership_mailer_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe ProMembershipMailer, type: :mailer do
expect(email.subject).to eq("Your Pro Membership will expire in 7 days!")
expect(email.to).to eq([user.email])
- expect(email.from).to eq(["yo@dev.to"])
+ expect(email.from).to eq([ApplicationConfig["DEFAULT_SITE_EMAIL"]])
end
end
diff --git a/spec/requests/user_settings_spec.rb b/spec/requests/user_settings_spec.rb
index d7ad58b5f..2f2cd6d30 100644
--- a/spec/requests/user_settings_spec.rb
+++ b/spec/requests/user_settings_spec.rb
@@ -232,7 +232,7 @@ RSpec.describe "UserSettings", type: :request do
it "sets the proper error message" do
delete "/users/remove_association", params: { provider: "github" }
expect(flash[:error]).
- to eq "An error occurred. Please try again or send an email to: yo@dev.to"
+ to eq "An error occurred. Please try again or send an email to: #{ApplicationConfig['DEFAULT_SITE_EMAIL']}"
end
it "does not delete any identities" do
- If you see too many of these, please report it to yo@dev.to! + If you see too many of these, please report it to "><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>!