Feature #11530

Support hooks in mailer

Added by Kouhei Sutou about 5 years ago. Updated about 1 month ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Email notifications
Target version:4.1.0
Resolution:

Description

Could you support hooks in mailer?

Views can be extended by plugin. I want to extend mail content by plugin.

I want to add newly added Wiki content to Wiki added notification mails.
I also want to add changed Wiki content diff to Wiki updated notification mails.

If Redmine supports hooks in mailer, I can write a plugin to do them.

0001-Support-hooks-in-mailer.patch Magnifier (3 KB) Kouhei Sutou, 2012-07-29 10:52

support-hooks-in-mailer-for-r10463.patch Magnifier (1.95 KB) Kouhei Sutou, 2012-09-24 04:25

support-hooks-in-mailer-for-r14648.patch Magnifier (1.94 KB) Kouhei Sutou, 2015-10-08 14:26

support-hooks-in-mailer-for-r16963.patch Magnifier (15.7 KB) okkez _, 2017-09-12 09:37


Related issues

Related to Redmine - Feature #12508: Add diff to wiki change notification New
Related to Redmine - Feature #26839: Inline Email Diff For Issue 'Description' Changes New

History

#1 Updated by Kouhei Sutou about 5 years ago

I attach a patch to support hooks in mailer.

We need to do two things to support hooks in mailer.

  1. Add view path of plugins to ActionView::Base
  2. Call call_hook in template

Here is the change for view path:

diff --git a/lib/redmine/plugin.rb b/lib/redmine/plugin.rb
index c3f4150..dae51ee 100644
--- a/lib/redmine/plugin.rb
+++ b/lib/redmine/plugin.rb
@@ -82,6 +82,7 @@ module Redmine #:nodoc:
       view_path = File.join(p.directory, 'app', 'views')
       if File.directory?(view_path)
         ActionController::Base.prepend_view_path(view_path)
+        ActionMailer::Base.prepend_view_path(view_path)
       end

       # Adds the app/{controllers,helpers,models} directories of the plugin to the autoload path

In the patch, just two call_hook are only added. We need more call_hook to make mailer more extensible.

#2 Updated by Kouhei Sutou about 5 years ago

Here is a plugin that uses hooks in mailer:
https://github.com/kou/redmine-plugin-wiki-change-notifier

If this feature request is accepted, the plugin works.

For now, the plugin works with the attached patch.

#3 Updated by Kouhei Sutou about 5 years ago

I've updated the patch because #11776 adds the following change:

diff --git a/lib/redmine/plugin.rb b/lib/redmine/plugin.rb
index c3f4150..dae51ee 100644
--- a/lib/redmine/plugin.rb
+++ b/lib/redmine/plugin.rb
@@ -82,6 +82,7 @@ module Redmine #:nodoc:
       view_path = File.join(p.directory, 'app', 'views')
       if File.directory?(view_path)
         ActionController::Base.prepend_view_path(view_path)
+        ActionMailer::Base.prepend_view_path(view_path)
       end

       # Adds the app/{controllers,helpers,models} directories of the plugin to the autoload path

#4 Updated by Toshi MARUYAMA over 3 years ago

  • Related to Feature #12508: Add diff to wiki change notification added

#5 Updated by Kouhei Sutou about 2 years ago

I've updated the patch for r14648.

#6 Updated by Go MAEDA about 2 years ago

Thank you for submitting patches.
Although the patch updates app/views/mailer/wiki_content_*.erb, I think other app/views/mailer/*.erb files should also have hooks for consistency.

#7 Updated by Kouhei Sutou about 2 years ago

Thanks for your response.
I'll also update other files when a developer accepts this request.

#8 Updated by okkez _ about 1 month ago

I've updated the patch for r16963.
This patch also includes changes for adding hooks to app/views/mailer/*.erb same as app/views/mailer/wiki_content_*.erb.

I hope that next major release includes this patch.

#9 Updated by Go MAEDA about 1 month ago

  • Target version set to 4.1.0

okkez _ wrote:

I've updated the patch for r16963.
This patch also includes changes for adding hooks to app/views/mailer/*.erb same as app/views/mailer/wiki_content_*.erb.

It looks good to me. I am setting target version to 4.1.0.
Thank you for posting the patch.

#10 Updated by Toshi MARUYAMA 20 days ago

  • Related to Feature #26839: Inline Email Diff For Issue 'Description' Changes added

Also available in: Atom PDF