Search code examples
redminetemplate-enginemailer

How to modify the redmine mailer templates?


I'm trying to strip posted messages from forum and the issues. The wiki doesn't send such information by default. The trouble is, that data entered in the body of forum posts or issues might be sensitive and I don't want it flying around the internet unencrypted. We can tolerate (and in fact want) some data being sent. For instance the title of a forum topic or the issue meta-fields to be sent. But the free-form text should be held back.

I found the templates in app/views/mailer but having extremely little knowledge of ruby I find myself unable to modify the issue template. The forum message template was straightforward to change, but this:

<% for detail in @journal.details -%>
<%= show_detail(detail, true) %>
<% end -%>

<%= @journal.notes if @journal.notes? %>
----------------------------------------
<%= render :partial => "issue_text_plain", :locals => { :issue => @issue, :issue_url => @issue_url } %>

is quite unintelligible to me.

Is there a documentation of how the templates work or which fields are available?


Solution

  • It was surprisingly easy to remove the content while keeping the data I wanted. Here's the patch I went with for future reference.

    diff -u mailer.orig/issue_add.text.plain.rhtml mailer/issue_add.text.plain.rhtml
    --- mailer.orig/issue_add.text.plain.rhtml    2014-11-12 22:13:17.024224309 +0100
    +++ mailer/issue_add.text.plain.rhtml    2014-11-12 23:22:57.634311578 +0100
    @@ -1,4 +1 @@
     <%= l(:text_issue_added, :id => "##{@issue.id}", :author => @issue.author) %>
    -
    -----------------------------------------
    -<%= render :partial => "issue_text_plain", :locals => { :issue => @issue, :issue_url => @issue_url } %>
    diff -u mailer.orig/issue_edit.text.plain.rhtml mailer/issue_edit.text.plain.rhtml
    --- mailer.orig/issue_edit.text.plain.rhtml    2014-11-12 22:13:17.024224309 +0100
    +++ mailer/issue_edit.text.plain.rhtml    2014-11-12 23:21:06.974188526 +0100
    @@ -3,7 +3,3 @@
     <% for detail in @journal.details -%>
     <%= show_detail(detail, true) %>
     <% end -%>
    -
    -<%= @journal.notes if @journal.notes? %>
    -----------------------------------------
    -<%= render :partial => "issue_text_plain", :locals => { :issue => @issue, :issue_url => @issue_url } %>
    diff -u mailer.orig/message_posted.text.plain.rhtml mailer/message_posted.text.plain.rhtml
    --- mailer.orig/message_posted.text.plain.rhtml    2014-11-12 22:13:17.024224309 +0100
    +++ mailer/message_posted.text.plain.rhtml    2014-11-12 23:20:51.057200772 +0100
    @@ -1,4 +1,2 @@
     <%= @message_url %>
     <%= @message.author %>
    -
    -<%= @message.content %>
    

    It's a really stupid 'fix' as it basically just removes lines, but it appears to work.