Skip to content

Commit 6f55cf8

Browse files
committed
Additional headers for nosymessage
Nice if a message needs to be marked as urgent or similar, e.g., Outlook uses an "Importance" header, when set to "high" it highlights the message.
1 parent 5ec0e62 commit 6f55cf8

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ onwards Python 3.4 and later are also supported.
1616

1717
Features:
1818

19+
- Allow to pass additional headers to nosymessage, nice if a message
20+
needs to be marked as urgent or similar, e.g., Outlook uses an
21+
"Importance" header, when set to "high" it highlights the message.
22+
(Ralf Schlatterbeck)
23+
1924
Fixed:
2025

2126
- issue2550996 - Give better error message when running with -c

roundup/roundupdb.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def addmessage(self, issueid, summary, text):
224224
def nosymessage(self, issueid, msgid, oldvalues, whichnosy='nosy',
225225
from_address=None, cc=[], bcc=[], cc_emails = [],
226226
bcc_emails = [], subject=None,
227-
note_filter = None):
227+
note_filter = None, add_headers={}):
228228
"""Send a message to the members of an issue's nosy list.
229229
230230
The message is sent only to users on the nosy list who are not
@@ -270,6 +270,9 @@ def nosymessage(self, issueid, msgid, oldvalues, whichnosy='nosy',
270270
prototype:
271271
note_filter(original_note, issueid, newvalues, oldvalues)
272272
If called, note_filter returns the new value for the message body.
273+
274+
The add_headers parameter allows to set additional headers for
275+
the outgoing email.
273276
"""
274277
encrypt = self.db.config.PGP_ENABLE and self.db.config.PGP_ENCRYPT
275278
pgproles = self.db.config.PGP_ROLES
@@ -364,10 +367,12 @@ def good_recipient(userid):
364367
self.db.msg.set(msgid, recipients=recipients)
365368
if sendto['plain'] or bcc_sendto['plain']:
366369
self.send_message(issueid, msgid, note, sendto['plain'],
367-
from_address, bcc_sendto['plain'], subject)
370+
from_address, bcc_sendto['plain'],
371+
subject, add_headers=add_headers)
368372
if sendto['crypt'] or bcc_sendto['crypt']:
369373
self.send_message(issueid, msgid, note, sendto['crypt'],
370-
from_address, bcc_sendto['crypt'], subject, crypt=True)
374+
from_address, bcc_sendto['crypt'], subject, crypt=True,
375+
add_headers=add_headers)
371376

372377
# backwards compatibility - don't remove
373378
sendmessage = nosymessage
@@ -404,9 +409,10 @@ def encrypt_to(self, message, sendto):
404409
return msg
405410

406411
def send_message(self, issueid, msgid, note, sendto, from_address=None,
407-
bcc_sendto=[], subject=None, crypt=False):
412+
bcc_sendto=[], subject=None, crypt=False, add_headers={}):
408413
'''Actually send the nominated message from this issue to the sendto
409-
recipients, with the note appended.
414+
recipients, with the note appended. It's possible to add
415+
headers to the message with the add_headers variable.
410416
'''
411417
users = self.db.user
412418
messages = self.db.msg
@@ -604,6 +610,14 @@ def send_message(self, issueid, msgid, note, sendto, from_address=None,
604610
message[header] = values
605611
except UnicodeError:
606612
message[header] = Header(values, charset)
613+
# Generate additional headers
614+
for k in add_headers:
615+
v = add_headers[k]
616+
try:
617+
v.encode('ascii')
618+
message[k] = v
619+
except UnicodeError:
620+
message[k] = Header(v, charset)
607621

608622
if not inreplyto:
609623
# Default the reply to the first message

0 commit comments

Comments
 (0)