-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[WIP] Issue #4209 - Add deliver_later option in send_devise_notification #4224
[WIP] Issue #4209 - Add deliver_later option in send_devise_notification #4224
Conversation
* Add private method devliery_method in models/authenticatable * Modify send_devise_notification by use delivery_method
deliver_later_option
@@ -187,8 +191,9 @@ def devise_mailer | |||
def send_devise_notification(notification, *args) | |||
message = devise_mailer.send(notification, self, *args) | |||
# Remove once we move to Rails 4.2+ only. | |||
|
|||
if message.respond_to?(:deliver_now) |
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 think we can remove this if
now, right? 😄
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.
@HexterCH what do you think of this? I guess that's the only pending piece we have here.
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.
@lucasmazza , but if remove this if
, that meanings if user's environment don't support deliver_now
or deliver_later
will failed.
And really sorry about that I respond so lately. 😭
@HexterCH thanks for tackling this, can you please add a small test case that asserts that the email is enqueued when the config is on? |
@@ -286,6 +286,10 @@ module Test | |||
mattr_accessor :token_generator | |||
@@token_generator = nil | |||
|
|||
# Store devise notification delivery method, default is deliver now | |||
mattr_accessor :deliver_later_option |
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.
We should add a new commenting section to the initializer template to document this for new apps.
Sure, I am working on it. 😄 |
…st case for deliver_later_option
81e48fd
to
5329b61
Compare
I am stuck on this test, any relative test that I can reference ? 🆘 |
@HexterCH exactly what I want! Waiting anxiously. |
@HexterCH Thanks for your contribution, we appreciate it! Your test failed in builds for rails 4.2 and
We can solve this issue by including the module in our # test/rails_app/app/mongoid/user.rb
require 'shared_user'
class User
include Mongoid::Document
include Shim
include SharedUser
+ # Required for ActiveJob serialization. Reference: http://edgeguides.rubyonrails.org/active_job_basics.html#globalid
+ include GlobalID::Identification |
I'm closing this since it has been here for a long time and probably will be too hard to rebase it. Thank you! |
Re-opens [heartcombo#4224][] By default, all `Devise::Models::Authenticatable`-initiated Action Mailer deliveries are transmitted immediately (within the request-response cycle). Transmitting emails and interacting with any third-party services over SMTP or HTTP risk service outages and other types of network-related failures. This commit adds support for deferring delivery to be done from an Action Job background worker queue through the [deliver_later][] method. ```ruby # config/initializers/devise.rb Devise.mailer_delivery_method = :deliver_later ``` [heartcombo#4224]: heartcombo#4224 [deliver_now]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_now [deliver_later]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_later
Re-opens [heartcombo#4224][] By default, all `Devise::Models::Authenticatable`-initiated Action Mailer deliveries are transmitted immediately (within the request-response cycle). Transmitting emails and interacting with any third-party services over SMTP or HTTP risk service outages and other types of network-related failures. This commit adds support for deferring delivery to be done from an Action Job background worker queue through the [deliver_later][] method. ```ruby # config/initializers/devise.rb Devise.mailer_delivery_method = :deliver_later ``` [heartcombo#4224]: heartcombo#4224 [deliver_now]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_now [deliver_later]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_later
Re-opens [heartcombo#4224][] By default, all `Devise::Models::Authenticatable`-initiated Action Mailer deliveries are transmitted immediately (within the request-response cycle). Transmitting emails and interacting with any third-party services over SMTP or HTTP risk service outages and other types of network-related failures. This commit adds support for deferring delivery to be done from an Action Job background worker queue through the [deliver_later][] method. ```ruby # config/initializers/devise.rb Devise.mailer_delivery_method = :deliver_later ``` [heartcombo#4224]: heartcombo#4224 [deliver_now]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_now [deliver_later]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_later
Re-opens [heartcombo#4224][] By default, all `Devise::Models::Authenticatable`-initiated Action Mailer deliveries are transmitted immediately (within the request-response cycle). Transmitting emails and interacting with any third-party services over SMTP or HTTP risk service outages and other types of network-related failures. This commit adds support for deferring delivery to be done from an Action Job background worker queue through the [deliver_later][] method. ```ruby # config/initializers/devise.rb Devise.mailer_delivery_method = :deliver_later ``` [heartcombo#4224]: heartcombo#4224 [deliver_now]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_now [deliver_later]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_later
Re-opens [heartcombo#4224][] By default, all `Devise::Models::Authenticatable`-initiated Action Mailer deliveries are transmitted immediately (within the request-response cycle). Transmitting emails and interacting with any third-party services over SMTP or HTTP risk service outages and other types of network-related failures. This commit adds support for deferring delivery to be done from an Action Job background worker queue through the [deliver_later][] method. ```ruby # config/initializers/devise.rb Devise.mailer_delivery_method = :deliver_later ``` [heartcombo#4224]: heartcombo#4224 [deliver_now]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_now [deliver_later]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_later
#4209
Add a class variable
deliver_later_option
and modify the methodsend_devise_notification
Now you can just add
config.deliver_later_option = true
in yourconfig/initailizers/devise.rb
, and devise mailer will usedeliver_later
to send every letter.Hope to get some feedback. 😄