https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292012-07-29T08:52:18ZRedmineRedmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=400212012-07-29T08:52:18ZKouhei Sutou
<ul><li><strong>File</strong> <a href="/attachments/8022">0001-Support-hooks-in-mailer.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/8022/0001-Support-hooks-in-mailer.patch">0001-Support-hooks-in-mailer.patch</a> added</li></ul><p>I attach a patch to support hooks in mailer.</p>
<p>We need to do two things to support hooks in mailer.</p>
<ol>
<li>Add view path of plugins to ActionView::Base</li>
<li>Call <code>call_hook</code> in template</li>
</ol>
<p>Here is the change for view path:<br /><pre>
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
</pre></p>
<p>In the patch, just two <code>call_hook</code> are only added. We need more <code>call_hook</code> to make mailer more extensible.</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=400222012-07-29T09:04:28ZKouhei Sutou
<ul></ul><p>Here is a plugin that uses hooks in mailer:<br /><a class="external" href="https://github.com/kou/redmine-plugin-wiki-change-notifier">https://github.com/kou/redmine-plugin-wiki-change-notifier</a></p>
<p>If this feature request is accepted, the plugin works.</p>
<p>For now, the plugin works with the attached patch.</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=411292012-09-24T02:25:18ZKouhei Sutou
<ul><li><strong>File</strong> <a href="/attachments/8244">support-hooks-in-mailer-for-r10463.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/8244/support-hooks-in-mailer-for-r10463.patch">support-hooks-in-mailer-for-r10463.patch</a> added</li></ul><p>I've updated the patch because <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Defect: Can't override mailer views inside redmine plugin. (Closed)" href="https://www.redmine.org/issues/11776">#11776</a> adds the following change:</p>
<pre>
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
</pre> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=562162014-05-09T04:27:17ZToshi MARUYAMA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-1 priority-4 priority-default" href="/issues/12508">Feature #12508</a>: Add diff to wiki change notification</i> added</li></ul> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=665392015-10-08T12:27:22ZKouhei Sutou
<ul><li><strong>File</strong> <a href="/attachments/14377">support-hooks-in-mailer-for-r14648.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/14377/support-hooks-in-mailer-for-r14648.patch">support-hooks-in-mailer-for-r14648.patch</a> added</li></ul><p>I've updated the patch for <a class="changeset" title="Set autologin cookie as secure by default when using https (#20935)." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/14648">r14648</a>.</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=665412015-10-08T13:05:00ZGo MAEDA
<ul></ul><p>Thank you for submitting patches.<br />Although the patch updates app/views/mailer/wiki_content_*.erb, I think other app/views/mailer/*.erb files should also have hooks for consistency.</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=665422015-10-08T13:22:17ZKouhei Sutou
<ul></ul><p>Thanks for your response.<br />I'll also update other files when a developer accepts this request.</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=810442017-09-12T07:40:50Zokkez _
<ul><li><strong>File</strong> <a href="/attachments/19141">support-hooks-in-mailer-for-r16963.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/19141/support-hooks-in-mailer-for-r16963.patch">support-hooks-in-mailer-for-r16963.patch</a> added</li></ul><p>I've updated the patch for <a class="changeset" title="add test that anonymous user can add watchers by mail (#26654)" href="https://www.redmine.org/projects/redmine/repository/svn/revisions/16963">r16963</a>.<br />This patch also includes changes for adding hooks to app/views/mailer/*.erb same as app/views/mailer/wiki_content_*.erb.</p>
<p>I hope that next major release includes this patch.</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=811652017-09-15T14:37:42ZGo MAEDA
<ul><li><strong>Target version</strong> set to <i>4.1.0</i></li></ul><p>okkez _ wrote:</p>
<blockquote>
<p>I've updated the patch for <a class="changeset" title="add test that anonymous user can add watchers by mail (#26654)" href="https://www.redmine.org/projects/redmine/repository/svn/revisions/16963">r16963</a>.<br />This patch also includes changes for adding hooks to app/views/mailer/*.erb same as app/views/mailer/wiki_content_*.erb.</p>
</blockquote>
<p>It looks good to me. I am setting target version to 4.1.0.<br />Thank you for posting the patch.</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=813992017-10-04T11:11:44ZToshi MARUYAMA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-1 priority-4 priority-default" href="/issues/26839">Feature #26839</a>: Inline Email Diff For Issue 'Description' Changes</i> added</li></ul> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=924572019-06-20T07:44:05ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Target version</strong> changed from <i>4.1.0</i> to <i>Candidate for next major release</i></li></ul><p>We need to provide a way for the hook to know if we're rendering a html or plain text email.</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=924582019-06-20T07:50:58ZKouhei Sutou
<ul></ul><p>It's already provided.<br />If we're rendering a HTML email, <code>XXX.html.erb</code> is used.<br />If we're rendering a plain text email, <code>XXX.text.erb</code> is used.</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=924662019-06-20T08:13:37ZJean-Philippe Langjp_lang@yahoo.fr
<ul></ul><p>Kouhei Sutou wrote:</p>
<blockquote>
<p>It's already provided.<br />If we're rendering a HTML email, <code>XXX.html.erb</code> is used.<br />If we're rendering a plain text email, <code>XXX.text.erb</code> is used.</p>
</blockquote>
<p>Sure, but how does the hook that is called know about this?</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=929012019-07-30T09:30:13ZKouhei Sutou
<ul></ul><p>We can get <code>:text</code> in <code>XXX.text.erb</code> and <code>:html</code> in <code>XXX.html.erb</code> by calling <code>lookup_context.rendered_format</code>.<br />We can also get <code>[:text]</code> in <code>XXX.text.erb</code> and <code>[:html]</code> in <code>XXX.html.erb</code> by calling <code>formats</code>.</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=947732019-11-05T07:46:42ZKouhei Sutou
<ul><li><strong>File</strong> <a href="/attachments/24282">support-hooks-in-mailer-for-r18899.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/24282/support-hooks-in-mailer-for-r18899.patch">support-hooks-in-mailer-for-r18899.patch</a> added</li></ul><p>I've updated the patch for <a class="changeset" title="Remove unused i18n key "button_duplicate" (#32400). Patch by Go MAEDA." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/18899">r18899</a>.</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=947742019-11-05T09:49:27ZKouhei Sutou
<ul><li><strong>File</strong> <a href="/attachments/24285">support-hooks-in-mailer-for-r18899-2.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/24285/support-hooks-in-mailer-for-r18899-2.patch">support-hooks-in-mailer-for-r18899-2.patch</a> added</li></ul><p>I added more hooks to `app/views/mailer/issue_edit*`:</p>
<pre><code class="diff syntaxhl"><span class="gd">--- support-hooks-in-mailer-for-r18899.patch 2019-11-05 16:44:11.906980336 +0900
</span><span class="gi">+++ support-hooks-in-mailer-for-r18899-2.patch 2019-11-05 18:46:16.355343392 +0900
</span><span class="p">@@ -132,28 +132,68 @@</span>
===================================================================
--- app/views/mailer/issue_edit.html.erb (revision 18899)
+++ app/views/mailer/issue_edit.html.erb (working copy)
<span class="gd">-@@ -13,3 +13,8 @@
</span><span class="gi">+@@ -10,6 +10,28 @@
+ <% end %>
+ </ul>
+
++<%= call_hook(:view_mailer_issue_edit_after_details,
++ :issue => @issue,
++ :journal => @journal,
++ :journal_details => @journal_details,
++ :users => @users,
++ :issue_url => @issue_url) %>
++
</span> <%= textilizable(@journal, :notes, :only_path => false) %>
<span class="gi">++
++<%= call_hook(:view_mailer_issue_edit_after_notes,
++ :issue => @issue,
++ :journal => @journal,
++ :journal_details => @journal_details,
++ :users => @users,
++ :issue_url => @issue_url) %>
++
</span> <hr />
<%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :user => @user, :issue_url => @issue_url } %>
+
+<%= call_hook(:view_mailer_issue_edit_bottom,
+ :issue => @issue,
<span class="gi">++ :journal => @journal,
++ :journal_details => @journal_details,
</span> + :users => @users,
+ :issue_url => @issue_url) %>
Index: app/views/mailer/issue_edit.text.erb
===================================================================
--- app/views/mailer/issue_edit.text.erb (revision 18899)
+++ app/views/mailer/issue_edit.text.erb (working copy)
<span class="gd">-@@ -10,3 +10,8 @@
</span><span class="gi">+@@ -3,10 +3,27 @@
+ <% details_to_strings(@journal_details, true).each do |string| -%>
+ <%= string %>
+ <% end -%>
+-
++<%= call_hook(:view_mailer_issue_edit_after_details,
++ :issue => @issue,
++ :journal => @journal,
++ :journal_details => @journal_details,
++ :users => @users,
++ :issue_url => @issue_url) -%>
+ <% if @journal.notes? -%>
+ <%= @journal.notes %>
+
</span> <% end -%>
<span class="gi">++<%= call_hook(:view_mailer_issue_edit_after_notes,
++ :issue => @issue,
++ :journal => @journal,
++ :journal_details => @journal_details,
++ :users => @users,
++ :issue_url => @issue_url) -%>
</span> ----------------------------------------
<%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :user => @user, :issue_url => @issue_url } %>
<span class="gd">-+
</span> +<%= call_hook(:view_mailer_issue_edit_bottom,
+ :issue => @issue,
<span class="gi">++ :journal => @journal,
++ :journal_details => @journal_details,
</span> + :users => @users,
<span class="gd">-+ :issue_url => @issue_url) %>
</span><span class="gi">++ :issue_url => @issue_url) -%>
</span> Index: app/views/mailer/lost_password.html.erb
===================================================================
--- app/views/mailer/lost_password.html.erb (revision 18899)
</code></pre> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=947752019-11-05T10:27:02ZKouhei Sutou
<ul><li><strong>File</strong> <a href="/attachments/24286">support-hooks-in-mailer-for-r18899-3.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/24286/support-hooks-in-mailer-for-r18899-3.patch">support-hooks-in-mailer-for-r18899-3.patch</a> added</li></ul><p>Sorry... I added one more cosmetic fix...</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=1040692021-09-07T21:46:54ZKouhei Sutou
<ul><li><strong>File</strong> <a href="/attachments/28020">support-hooks-in-mailer-for-r21217.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/28020/support-hooks-in-mailer-for-r21217.patch">support-hooks-in-mailer-for-r21217.patch</a> added</li></ul><p>I've updated the patch for <a class="changeset" title="Fix NoMethodError when generating a link to a locked user (#12795, #35823)." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/21217">r21217</a>.</p> Redmine - Feature #11530: Support hooks in mailerhttps://www.redmine.org/issues/11530?journal_id=1065722022-05-01T20:30:54ZKouhei Sutou
<ul></ul><p>Could someone take a look at this?<br />We use this maintained patch in almost 10 years. We use this patch with Redmine 5.0.0 now.</p>