Vote #64662
未完了Send out issue priority in the email notification header
0%
説明
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.
journals
Why not use the more standard X-Priority header?
--------------------------------------------------------------------------------
Jean-Philippe Lang wrote:
> Why not use the more standard X-Priority header?
Hrm. The header "Priority":http://tools.ietf.org/html/rfc4021#section-2.1.54 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?
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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
--------------------------------------------------------------------------------
I'd really prefer not to add an extra field just for this purpose.
Is there any problem with the solution I propose?
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
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?
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
The following patch adds a standard Priority field defined in "RFC 2156":https://datatracker.ietf.org/doc/html/rfc2156. The priority values are mapped to one of "normal", "urgent", or "non-urgent".
<pre><code class="diff">
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)
</code></pre>
--------------------------------------------------------------------------------
Added test code to #2746#note-12.
--------------------------------------------------------------------------------
Setting the target version to 5.0.0.
--------------------------------------------------------------------------------
Go MAEDA wrote:
> The following patch adds a standard Priority field defined in "RFC 2156":https://datatracker.ietf.org/doc/html/rfc2156. 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":https://datatracker.ietf.org/doc/html/rfc2076#section-3.9 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.
--------------------------------------------------------------------------------
related_issues
relates,New,19939,New X-Redmine-Issue-Priority header, and modification of X-Redmine-Issue-Assignee
relates,New,12864,If ticket was created with priority High/Urgent, send smtp-email with priority Urgent
relates,Closed,31910,Add additional mail headers for issue tracker
duplicates,Closed,20443,Add Priority header to Email notifications
Admin Redmine さんが3年以上前に更新
- カテゴリ を Email notifications_9 にセット
- 対象バージョン を Candidate for next major release_32 にセット