Skip to content

Commit d0e3658

Browse files
committed
issue2109308 add subject argument to nosymessage. Initial patch Frank Niessink. Test and application with slight mods by rouilj
1 parent 4c83086 commit d0e3658

File tree

3 files changed

+70
-7
lines changed

3 files changed

+70
-7
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Features:
3737
errors now include the left hand menu, a proper page title and
3838
body content. Note added to doc/upgrading.txt on how to add it to
3939
deployed trackers. (John Rouillard)
40+
- issue2109308 - Allow subject of nosy messages be changed from reactor
41+
Adds a subject parameter to nosymessage function. Patch initally
42+
generated by Frank Niessink. Tests, adaptation by John Rouillard.
4043

4144
Fixed:
4245

roundup/roundupdb.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ def addmessage(self, issueid, summary, text):
227227
"""
228228

229229
def nosymessage(self, issueid, msgid, oldvalues, whichnosy='nosy',
230-
from_address=None, cc=[], bcc=[], cc_emails = [], bcc_emails = []):
230+
from_address=None, cc=[], bcc=[], cc_emails = [],
231+
bcc_emails = [], subject=None ):
231232
"""Send a message to the members of an issue's nosy list.
232233
233234
The message is sent only to users on the nosy list who are not
@@ -238,6 +239,12 @@ def nosymessage(self, issueid, msgid, oldvalues, whichnosy='nosy',
238239
If 'msgid' is None, the message gets sent only to the nosy
239240
list, and it's called a 'System Message'.
240241
242+
The "subject" argument is used as subject for the message. If no
243+
subject is passed, a subject will be generated from the message.
244+
Note the subject does not include the item designator [classID]
245+
prefix that allows proper processing of reply emails. The caller
246+
needs to include that label in the subject if needed.
247+
241248
The "cc" argument indicates additional recipients to send the
242249
message to that may not be specified in the message's recipients
243250
list.
@@ -248,12 +255,12 @@ def nosymessage(self, issueid, msgid, oldvalues, whichnosy='nosy',
248255
address lists. Note that the list of bcc users *is* updated in
249256
the recipient list of the message, so this field has to be
250257
protected (using appropriate permissions), otherwise the bcc
251-
will be decuceable for users who have web access to the tracker.
258+
will be deduceable for users who have web access to the tracker.
252259
253260
The cc_emails and bcc_emails arguments take a list of additional
254261
recipient email addresses (just the mail address not roundup users)
255262
this can be useful for sending to additional email addresses
256-
which are no roundup users. These arguments are currently not
263+
which are not roundup users. These arguments are currently not
257264
used by roundups nosyreaction but can be used by customized
258265
(nosy-)reactors.
259266
@@ -350,10 +357,10 @@ def good_recipient(userid):
350357
self.db.msg.set(msgid, recipients=recipients)
351358
if sendto['plain'] or bcc_sendto['plain']:
352359
self.send_message(issueid, msgid, note, sendto['plain'],
353-
from_address, bcc_sendto['plain'])
360+
from_address, bcc_sendto['plain'], subject)
354361
if sendto['crypt'] or bcc_sendto['crypt']:
355362
self.send_message(issueid, msgid, note, sendto['crypt'],
356-
from_address, bcc_sendto['crypt'], crypt=True)
363+
from_address, bcc_sendto['crypt'], subject, crypt=True)
357364

358365
# backwards compatibility - don't remove
359366
sendmessage = nosymessage
@@ -390,7 +397,7 @@ def encrypt_to(self, message, sendto):
390397
return msg
391398

392399
def send_message(self, issueid, msgid, note, sendto, from_address=None,
393-
bcc_sendto=[], crypt=False):
400+
bcc_sendto=[], subject=None, crypt=False):
394401
'''Actually send the nominated message from this issue to the sendto
395402
recipients, with the note appended.
396403
'''
@@ -498,7 +505,9 @@ def send_message(self, issueid, msgid, note, sendto, from_address=None,
498505
if from_tag:
499506
from_tag = ' ' + from_tag
500507

501-
subject = '[%s%s] %s'%(cn, issueid, title)
508+
if subject is None:
509+
subject = '[%s%s] %s'%(cn, issueid, title)
510+
502511
author = (authname + from_tag, from_address)
503512

504513
# send an individual message per recipient?

test/test_mailgw.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,57 @@ def testPropertyChangeOnly(self):
14071407
""")
14081408

14091409

1410+
def testNosyMessageSettingSubject(self):
1411+
self.doNewIssue()
1412+
oldvalues = self.db.getnode('issue', '1').copy()
1413+
oldvalues['assignedto'] = None
1414+
# reconstruct old behaviour: This would reuse the
1415+
# database-handle from the doNewIssue above which has committed
1416+
# as user "Chef". So we close and reopen the db as that user.
1417+
#self.db.close() actually don't close 'cos this empties memorydb
1418+
self.db = self.instance.open('Chef')
1419+
self.db.issue.set('1', assignedto=self.chef_id)
1420+
self.db.commit()
1421+
self.db.issue.nosymessage('1', None, oldvalues, subject="test")
1422+
1423+
new_mail = ""
1424+
for line in self._get_mail().split("\n"):
1425+
if "Message-Id: " in line:
1426+
continue
1427+
if "Date: " in line:
1428+
continue
1429+
new_mail += line+"\n"
1430+
1431+
self.compareMessages(new_mail, """
1432+
1433+
1434+
Content-Type: text/plain; charset="utf-8"
1435+
Subject: test
1436+
1437+
From: "Bork, Chef" <[email protected]>
1438+
X-Roundup-Name: Roundup issue tracker
1439+
X-Roundup-Loop: hello
1440+
X-Roundup-Issue-Status: unread
1441+
X-Roundup-Version: 1.3.3
1442+
In-Reply-To: <dummy_test_message_id>
1443+
MIME-Version: 1.0
1444+
Reply-To: Roundup issue tracker
1445+
1446+
Content-Transfer-Encoding: quoted-printable
1447+
1448+
1449+
Change by Bork, Chef <[email protected]>:
1450+
1451+
1452+
----------
1453+
assignedto: -> Chef
1454+
1455+
_______________________________________________________________________
1456+
Roundup issue tracker <[email protected]>
1457+
<http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
1458+
_______________________________________________________________________
1459+
""")
1460+
14101461
#
14111462
# FOLLOWUP TITLE MATCH
14121463
#

0 commit comments

Comments
 (0)