Project

General

Profile

Actions

Feature #28338

closed

Make Redmine Email Delivery compatible with ActiveJob

Added by Stephane Evr about 6 years ago. Updated over 5 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 #1

Updated by Go MAEDA about 6 years ago

  • Category set to Email notifications

I think the patch #26791 covers this issue.

Actions #2

Updated by Go MAEDA almost 6 years ago

  • Related to Feature #26791: Send individual notification mails per mail recipient added
Actions #3

Updated by Go MAEDA over 5 years ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Email delivery using ActiveJob was implemented by #26791.

Actions

Also available in: Atom PDF