Make The Default Email An Enviroment Variable. (#4677)

* Make the default email an enviroment variable

* Added spaces in Envfile for readability
This commit is contained in:
Mohab Abd El-Dayem 2019-11-01 15:03:06 +02:00 committed by Ben Halpern
parent f2ce926653
commit 2c80e9da42
25 changed files with 30 additions and 27 deletions

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -1,5 +1,5 @@
class ApplicationMailer < ActionMailer::Base
default from: "DEV Community <yo@dev.to>"
default from: "DEV Community <#{ApplicationConfig['DEFAULT_SITE_EMAIL']}>"
layout "mailer"
default template_path: ->(mailer) { "mailers/#{mailer.class.name.underscore}" }

View file

@ -1,5 +1,5 @@
class DigestMailer < ApplicationMailer
default from: "DEV Digest <yo@dev.to>"
default from: "DEV Digest <#{ApplicationConfig['DEFAULT_SITE_EMAIL']}>"
def digest_email(user, articles)
@user = user

View file

@ -1,5 +1,5 @@
class ProMembershipMailer < ApplicationMailer
default from: "DEV Pro Memberships <yo@dev.to>"
default from: "DEV Pro Memberships <#{ApplicationConfig['DEFAULT_SITE_EMAIL']}>"
def expiring_membership(pro_membership, expiration_date)
@pro_membership = pro_membership

View file

@ -33,7 +33,7 @@ class Organization < ApplicationRecord
format: { with: /\A[a-zA-Z0-9\-_]+\Z/ },
length: { in: 2..18 },
exclusion: { in: ReservedWords.all,
message: "%<value>s is a reserved word. Contact yo@dev.to for help registering your organization." }
message: "%<value>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

View file

@ -25,6 +25,6 @@
<%= flash[:alert] %>
<br>
<% end %>
Please try again below, or contact <a href="mailto:yo@dev.to">yo@dev.to</a> if this persists.
Please try again below, or contact <a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %></a> if this persists.
</div>
<% end %>

View file

@ -4,7 +4,7 @@
<h2>Thank you for your report.</h2>
<h3><a href="/">Return to home page</a></h3>
<p>
Questions? Send an email to <a href="mailto:yo@dev.to">yo@dev.to</a>
Questions? Send an email to <a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %></a>
</p>
</div>
</div>

View file

@ -7,7 +7,7 @@
</p>
<p>
Contact us at <a href="mailto:yo@dev.to">yo@dev.to</a> if there is anything more we can help with. 😊
Contact us at <a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %></a> if there is anything more we can help with. 😊
</p>
<p>

View file

@ -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

View file

@ -111,8 +111,8 @@
<%= HTML_Truncator.truncate(
article.processed_html,
200,
ellipsis: '<a class="comment-read-more" href="' + article.path + '">... Read Entire Post</a>').html_safe
%>
ellipsis: '<a class="comment-read-more" href="' + article.path + '">... Read Entire Post</a>',
).html_safe %>
</div>
<center>
<% if article.last_buffered.nil? %>
@ -150,7 +150,7 @@
<h1 style="text-align: center">DEV Mods</h1>
<div class="body">
<p>We periodically award some DEV members with heightened privileges to help moderate the community.</p>
<p>Email <a href="mailto:yo@dev.to">yo@dev.to</a> if you'd like to be considered right away.</p>
<p>Email <a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %></a> if you'd like to be considered right away.</p>
<% if !user_signed_in? %>
<p><em>P.S. You are not currently signed in.</em></p>
<% end %>

View file

@ -14,7 +14,7 @@
<div class="content notification-content comment-content">
An error occurred! This has been logged and we're tracking it.
<br>
If you see too many of these, please report it to <a href="mailto:yo@dev.to">yo@dev.to</a>!
If you see too many of these, please report it to <a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %></a>!
</div>
<% end %>

View file

@ -20,6 +20,6 @@
Check out <a href="/tags">other popular tags</a> which may be more appropriate.
<br><br />
Thanks for being part of DEV! If you feel like this mod action was a mistake, feel free to contact
<a href="mailto:yo@dev.to">yo@dev.to</a>. 🤗
<a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %></a>. 🤗
<br /><br />
</div>

View file

@ -30,7 +30,7 @@
The Practical Dev would love to hear from you!
</p>
<p>
Email: <a href="mailto:yo@dev.to">yo@dev.to</a> 😁
Email: <a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %></a> 😁
</p>
<p>
Twitter: <a href="http://twitter.com/<%= ApplicationConfig["SITE_TWITTER_HANDLE"] %>">@<%= ApplicationConfig["SITE_TWITTER_HANDLE"] %></a> 👻

View file

@ -25,7 +25,7 @@
<p>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 :)<br>By the way, you can also buy Swagnets that benefit open-source projects: you can check those out
<b><a href="https://www.swagnets.com/pages/activism">here</a></b>.<br>Comments? Suggestions? Ping us on Twitter or at
<a href="mailto:yo@dev.to">yo@dev.to</a>.</p>
<a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %></a>.</p>
</div>
</div>

View file

@ -28,7 +28,7 @@
</div>
</a>
<% end %>
<p>If you know of a great dev podcast that should be added to this list, contact <a href="mailto:yo@dev.to">yo@dev.to</a></p>
<p>If you know of a great dev podcast that should be added to this list, contact <a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %></a></p>
</div>
</div>
<% elsif @podcast %>

View file

@ -148,7 +148,7 @@
<h3>Request Account Deletion</h3>
<h4 style="font-weight: 400;">
<br>
<a href="mailto:yo@dev.to?subject=Request Account Deletion&body=<%= @email_body %>">
<a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>?subject=Request Account Deletion&body=<%= @email_body %>">
Click this link to request account deletion via email.
</a> This includes all articles, comments, reactions, etc. as well as any personal information you have.
<br>

View file

@ -26,7 +26,7 @@
</p>
<p>
Your feed will be fetched every time you submit this form and updates will be automatically fetched periodically thereafter. Contact
<a href="mailto:yo@dev.to">yo@dev.to</a> if you encounter issues.
<a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %></a> if you encounter issues.
</p>
<p>
FYI: Medium RSS feed URLs are <em>https://medium.com/feed/@your_username</em>

View file

@ -15,7 +15,7 @@
<% if params[:state] == "previous-registration" %>
<div class="notice error-notice" id="notice">
There is an existing account authorized with that social account. Contact
<a href="mailto:yo@dev.to">yo@dev.to</a> if this is a mistake.
<a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %></a> if this is a mistake.
</div>
<% end %>

View file

@ -33,7 +33,7 @@
<% end %>
<div style="margin:50px auto;max-width:80%;font-size:0.86em;">
<p>
<strong>Video is beta:</strong> Email <a href="mailto:yo@dev.to">yo@dev.to</a> if you have any problems.
<strong>Video is beta:</strong> Email <a href="mailto:<%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %>"><%= ApplicationConfig["DEFAULT_SITE_EMAIL"] %></a> if you have any problems.
</p>
</div>
</center>

View file

@ -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

View file

@ -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

View file

@ -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