Patch #2746

Send out issue priority in the email notification header

Added by Brad Beattie over 12 years ago. Updated 4 months ago.

Status:NewStart date:2009-02-13
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Email notifications
Target version:Candidate for next major release

Description

The attached patch will send out an issue's priority with the notification email's headers. This is important for when you want to route urgent tickets differently.

priority.patch Magnifier (938 Bytes) Brad Beattie, 2009-02-13 19:10

2746.patch Magnifier (2.82 KB) Go MAEDA, 2021-05-16 14:19


Related issues

Related to Redmine - Feature #19939: New X-Redmine-Issue-Priority header, and modification of ... New
Related to Redmine - Feature #12864: If ticket was created with priority High/Urgent, send smt... New
Related to Redmine - Feature #31910: Add additional mail headers for issue tracker Closed
Duplicated by Redmine - Feature #20443: Add Priority header to Email notifications Closed

History

#1 Updated by Jean-Philippe Lang over 12 years ago

Why not use the more standard X-Priority header?

#2 Updated by Brad Beattie over 12 years ago

  • Assignee set to Jean-Philippe Lang

Jean-Philippe Lang wrote:

Why not use the more standard X-Priority header?

Hrm. The header Priority has values "normal", "urgent" and "non-urgent". I can't find any RFC that defines the values of "X-Priority", but most examples I see use the values 1 through 5. While this maps up to Redmine's default priority values, other systems might have limited or extended these enumerations (e.g. my company uses "Low, Normal and Emergency". How would these modified values be mapped to X-Priority? 1, 3, 5? It's kinda vague, yeah?

I guess that's why I thought just creating a Redmine-specific priority header would be a better choice. What're your thoughts on this?

#3 Updated by Jean-Philippe Lang over 12 years ago

An other problem is that a X-Priority of 1 means urgent, whereas Redmine priorities are sorted in opposite order (1 = low).
We need to map Redmine priorities (max => 1, min => 5). Just need to retrieve the total numbers of priorities defined in Redmine.
So yes, if you have 3 priorities defined in Redmine, they would be mapped to X-Priority 1, 3 and 5.

#4 Updated by Thomas Pihl over 12 years ago

Other solution might be an extra field when defining priorities where you can choose x-priority manually for each priority. This might include an option not to send email for some priorities.

/T

#5 Updated by Jean-Philippe Lang over 12 years ago

I'd really prefer not to add an extra field just for this purpose.
Is there any problem with the solution I propose?

#6 Updated by Brad Beattie over 12 years ago

Jean-Philippe Lang wrote:

I'd really prefer not to add an extra field just for this purpose.
Is there any problem with the solution I propose?

Hrm. Yeah. Let's say we have two Redmine instances: one has priorities deferrable and normal, the other has priorities normal and emergency. How would you propose those two instances would be mapped? I don't see a way of automating this to ensure that any set of customized priorities get mapped properly to the X-Priority header. I guess that's why I suggested a Redmine-specific header.

#7 Updated by Go MAEDA about 6 years ago

  • Duplicated by Feature #20443: Add Priority header to Email notifications added

#8 Updated by Go MAEDA about 6 years ago

  • Related to Feature #19939: New X-Redmine-Issue-Priority header, and modification of X-Redmine-Issue-Assignee added

#9 Updated by Peter Volkov about 4 years ago

Guys what's left to do here? Can we have X-Redmine-Priority field at least and leave a question if we need standard Priority field and mapping for better times?

#10 Updated by Go MAEDA about 3 years ago

  • Related to Feature #12864: If ticket was created with priority High/Urgent, send smtp-email with priority Urgent added

#11 Updated by Go MAEDA about 2 years ago

  • Related to Feature #31910: Add additional mail headers for issue tracker added

#12 Updated by Go MAEDA 4 months ago

  • Assignee deleted (Jean-Philippe Lang)

The following patch adds a standard Priority field defined in RFC 2156. The priority values are mapped to one of "normal", "urgent", or "non-urgent".

diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index f58a1c88d..33b82a519 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -71,6 +71,7 @@ class Mailer < ActionMailer::Base

   # Builds a mail for notifying user about a new issue
   def issue_add(user, issue)
+    headers['Priority'] = priority_for_header(issue)
     redmine_headers 'Project' => issue.project.identifier,
                     'Issue-Tracker' => issue.tracker.name,
                     'Issue-Id' => issue.id,
@@ -103,6 +104,7 @@ class Mailer < ActionMailer::Base
   # Builds a mail for notifying user about an issue update
   def issue_edit(user, journal)
     issue = journal.journalized
+    headers['Priority'] = priority_for_header(issue)
     redmine_headers 'Project' => issue.project.identifier,
                     'Issue-Tracker' => issue.tracker.name,
                     'Issue-Id' => issue.id,
@@ -763,6 +765,17 @@ class Mailer < ActionMailer::Base
     h.each {|k, v| headers["X-Redmine-#{k}"] = v.to_s}
   end

+  def priority_for_header(issue)
+    position_name = issue.priority.position_name
+    if position_name.start_with?('high')
+      'urgent'
+    elsif position_name.start_with?('low')
+      'non-urgent'
+    else
+      'normal'
+    end
+  end
+
   # Singleton class method is public
   class << self
     def token_for(object, user)

#13 Updated by Go MAEDA 4 months ago

  • File 2746.patchMagnifier added
  • Target version set to Candidate for next major release

Added test code to #2746#note-12.

#14 Updated by Go MAEDA 4 months ago

  • Target version changed from Candidate for next major release to 5.0.0

Setting the target version to 5.0.0.

#15 Updated by Go MAEDA 4 months ago

  • Target version changed from 5.0.0 to Candidate for next major release

Go MAEDA wrote:

The following patch adds a standard Priority field defined in RFC 2156. The priority values are mapped to one of "normal", "urgent", or "non-urgent".

I found that it is not appropriate to use the Priority header to express issue priorities because the header is related to QoS control of mail delivery. RFC2076 says the header "can influence transmission speed and delivery".

Since issue priority has nothing to do with mail delivery priority, it is wrong to use the Priority header to express issue priority.

Also available in: Atom PDF