-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-add dynamic delivery_method for ApplicationMailer #13994
Conversation
@@ -9,7 +9,7 @@ def perform(follow_id, mailer = NotifyMailer.name) | |||
|
|||
return if EmailMessage.where(user_id: follow.followable_id) | |||
.where("sent_at > ?", rand(15..35).hours.ago) | |||
.exists?(["subject LIKE ?", "%#{NotifyMailer.subjects[:new_follower_email]}"]) | |||
.exists?(["subject LIKE ?", "%#{NotifyMailer.new.subjects[:new_follower_email]}"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I unintentionally found out that this is a syntax error and this code may have been broken the whole time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maestromac A syntax error? Not a NoMethodError
? 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@citizen428 ah yup I meant NoMethodError
@@ -48,6 +46,6 @@ def set_perform_deliveries | |||
protected | |||
|
|||
def set_delivery_options | |||
self.smtp_settings = Settings::SMTP.settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out this is the incorrect way to update SMTP config. In spec, checking ActionMailer::Base.deliveries.last.deliver_methods
after any email is sent out would return {}
.
Keeping it draft, for now, to test it on Canary first. |
@@ -0,0 +1,16 @@ | |||
module Deliverable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more like a placeholder. Happy to take any naming suggestion here
Deployed this to canary1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this!
end | ||
|
||
def set_delivery_options | ||
mail.delivery_method.settings.merge!(Settings::SMTP.settings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this incorporate SENDGRID_API_KEY
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Settings::SMTP.settings
returns a hardcoded config if SENDGRID_API_KEY
exists.
See https://github.com/forem/forem/blob/main/app/models/settings/smtp.rb#L20
@@ -4,7 +4,7 @@ | |||
let(:user) { create(:user) } | |||
let(:email) { VerificationMailer.with(user_id: user.id).account_ownership_verification_email } | |||
|
|||
xdescribe "#set_perform_deliveries" do | |||
describe "#set_perform_deliveries" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick, non-blocking: I think this is a Deliverable test, not specifically an ApplicationMailer test.
What type of PR is this? (check all applicable)
Description
The reason my previous attempt in #13943 did not work is most likely due setting
smtp_settings
improperly in the callback. This PR should fix with by alteringdelivery_method.settings
instead.Related Tickets & Documents
#13943
QA Instructions, Screenshots, Recordings
n/a
Added/updated tests?
[Forem core team only] How will this change be communicated?
[optional] Are there any post deployment tasks we need to perform?
QA on Canary first.