Project

General

Profile

Actions

Feature #28338

closed

Make Redmine Email Delivery compatible with ActiveJob

Added by Stephane Evr over 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Email notifications
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

Description

I have started implementing a Resque backend for Redmine (with the redmine_resque plugin) in order to process some background jobs as well as emails. The following is about what I had to do in order to make the email delivery work properly. I have as well found some bugs which can be fixed easily.

  • In config/initializers/10-patches.rb
# #deliver is deprecated in Rails 4.2
# Prevents massive deprecation warnings
module ActionMailer
  class MessageDelivery < Delegator
    def deliver
      deliver_later # instead of deliver_now
    end
  end
end
  • In config/configuration.yml

use SMTP instead of ASYNC SMTP, no need to pass the email processing to a thread.

The emails should then be processed by the background job backend.

I however ran into some issues, where some notification emails would cause the following error:

ActiveJob::SerializationError: Unsupported argument type: Symbol

I found that this was caused by the following arguments being passed from the Mailer model to ActiveJob (there are several places in the code):

# Notifies user that his password was updated
  def self.password_updated(user)
    return if user.admin? && user.login == 'admin' && user.mail == 'admin@example.net'

    security_notification(user,
      message: :mail_body_password_updated, # <--- THIS ARG
      title: :button_change_password, # <--- THIS ARG
      url: {controller: 'my', action: 'password'}
    ).deliver
  end

Which needs to be replaced with:

# Notifies user that his password was updated
  def self.password_updated(user)
    return if user.admin? && user.login == 'admin' && user.mail == 'admin@example.net'

    security_notification(user,
      message: "mail_body_password_updated", # <--- THIS ARG
      title: "button_change_password", # <--- THIS ARG
      url: {controller: 'my', action: 'password'}
    ).deliver
  end

As ActiveJob is not able to process parameters as symbols.


Related issues

Related to Redmine - Feature #26791: Send individual notification mails per mail recipientClosedJean-Philippe Lang

Actions
Actions

Also available in: Atom PDF