Skip to content

Commit 121d9bb

Browse files
author
Richard Jones
committed
The email for the first message on an issue...
...was sometimes having its In-Reply-To set to itself (thanks Eric Kow). Also fix roundupdb IssueClass code to use the variable "issueid" instead of the braindead "nodeid".
1 parent e7e62f2 commit 121d9bb

File tree

4 files changed

+84
-30
lines changed

4 files changed

+84
-30
lines changed

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first.
33

4+
2010-02-23 1.5.0
5+
6+
Fixed:
7+
- The email for the first message on an issue was having its In-Reply-To
8+
set to itself (thanks Eric Kow)
9+
10+
411
2010-02-19 1.4.13
512

613
Fixed:

roundup/roundupdb.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class IssueClass:
179179
)
180180

181181
# New methods:
182-
def addmessage(self, nodeid, summary, text):
182+
def addmessage(self, issueid, summary, text):
183183
"""Add a message to an issue's mail spool.
184184
185185
A new "msg" node is constructed using the current date, the user that
@@ -192,7 +192,7 @@ def addmessage(self, nodeid, summary, text):
192192
appended to the "messages" field of the specified issue.
193193
"""
194194

195-
def nosymessage(self, nodeid, msgid, oldvalues, whichnosy='nosy',
195+
def nosymessage(self, issueid, msgid, oldvalues, whichnosy='nosy',
196196
from_address=None, cc=[], bcc=[]):
197197
"""Send a message to the members of an issue's nosy list.
198198
@@ -263,7 +263,7 @@ def good_recipient(userid):
263263
seen_message[authid] = 1
264264

265265
# now deal with the nosy and cc people who weren't recipients.
266-
for userid in cc + self.get(nodeid, whichnosy):
266+
for userid in cc + self.get(issueid, whichnosy):
267267
if good_recipient(userid):
268268
add_recipient(userid, sendto)
269269

@@ -273,24 +273,24 @@ def good_recipient(userid):
273273
add_recipient(userid, bcc_sendto)
274274

275275
if oldvalues:
276-
note = self.generateChangeNote(nodeid, oldvalues)
276+
note = self.generateChangeNote(issueid, oldvalues)
277277
else:
278-
note = self.generateCreateNote(nodeid)
278+
note = self.generateCreateNote(issueid)
279279

280280
# If we have new recipients, update the message's recipients
281281
# and send the mail.
282282
if sendto or bcc_sendto:
283283
if msgid is not None:
284284
self.db.msg.set(msgid, recipients=recipients)
285-
self.send_message(nodeid, msgid, note, sendto, from_address,
285+
self.send_message(issueid, msgid, note, sendto, from_address,
286286
bcc_sendto)
287287

288288
# backwards compatibility - don't remove
289289
sendmessage = nosymessage
290290

291-
def send_message(self, nodeid, msgid, note, sendto, from_address=None,
291+
def send_message(self, issueid, msgid, note, sendto, from_address=None,
292292
bcc_sendto=[]):
293-
'''Actually send the nominated message from this node to the sendto
293+
'''Actually send the nominated message from this issue to the sendto
294294
recipients, with the note appended.
295295
'''
296296
users = self.db.user
@@ -309,14 +309,14 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None,
309309
# this is an old message that didn't get a messageid, so
310310
# create one
311311
messageid = "<%s.%s.%s%s@%s>"%(time.time(), random.random(),
312-
self.classname, nodeid,
312+
self.classname, issueid,
313313
self.db.config.MAIL_DOMAIN)
314314
if msgid is not None:
315315
messages.set(msgid, messageid=messageid)
316316

317317
# compose title
318318
cn = self.classname
319-
title = self.get(nodeid, 'title') or '%s message copy'%cn
319+
title = self.get(issueid, 'title') or '%s message copy'%cn
320320

321321
# figure author information
322322
if msgid:
@@ -338,11 +338,11 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None,
338338

339339
# put in roundup's signature
340340
if self.db.config.EMAIL_SIGNATURE_POSITION == 'top':
341-
m.append(self.email_signature(nodeid, msgid))
341+
m.append(self.email_signature(issueid, msgid))
342342

343343
# add author information
344344
if authid and self.db.config.MAIL_ADD_AUTHORINFO:
345-
if msgid and len(self.get(nodeid, 'messages')) == 1:
345+
if msgid and len(self.get(issueid, 'messages')) == 1:
346346
m.append(_("New submission from %(authname)s%(authaddr)s:")
347347
% locals())
348348
elif msgid:
@@ -377,7 +377,7 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None,
377377

378378
# put in roundup's signature
379379
if self.db.config.EMAIL_SIGNATURE_POSITION == 'bottom':
380-
m.append(self.email_signature(nodeid, msgid))
380+
m.append(self.email_signature(issueid, msgid))
381381

382382
# figure the encoding
383383
charset = getattr(self.db.config, 'EMAIL_CHARSET', 'utf-8')
@@ -397,7 +397,7 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None,
397397
if from_tag:
398398
from_tag = ' ' + from_tag
399399

400-
subject = '[%s%s] %s'%(cn, nodeid, title)
400+
subject = '[%s%s] %s'%(cn, issueid, title)
401401
author = (authname + from_tag, from_address)
402402

403403
# send an individual message per recipient?
@@ -441,12 +441,12 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None,
441441
if not 'name' in cl.getprops():
442442
continue
443443
if isinstance(prop, hyperdb.Link):
444-
value = self.get(nodeid, propname)
444+
value = self.get(issueid, propname)
445445
if value is None:
446446
continue
447447
values = [value]
448448
else:
449-
values = self.get(nodeid, propname)
449+
values = self.get(issueid, propname)
450450
if not values:
451451
continue
452452
values = [cl.get(v, 'name') for v in values]
@@ -459,11 +459,11 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None,
459459

460460
if not inreplyto:
461461
# Default the reply to the first message
462-
msgs = self.get(nodeid, 'messages')
462+
msgs = self.get(issueid, 'messages')
463463
# Assume messages are sorted by increasing message number here
464464
# If the issue is just being created, and the submitter didn't
465465
# provide a message, then msgs will be empty.
466-
if msgs and msgs[0] != nodeid:
466+
if msgs and msgs[0] != msgid:
467467
inreplyto = messages.get(msgs[0], 'messageid')
468468
if inreplyto:
469469
message['In-Reply-To'] = inreplyto
@@ -515,7 +515,7 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None,
515515
mailer.smtp_send(sendto, message.as_string())
516516
first = False
517517

518-
def email_signature(self, nodeid, msgid):
518+
def email_signature(self, issueid, msgid):
519519
''' Add a signature to the e-mail with some useful information
520520
'''
521521
# simplistic check to see if the url is valid,
@@ -528,7 +528,7 @@ def email_signature(self, nodeid, msgid):
528528
else:
529529
if not base.endswith('/'):
530530
base = base + '/'
531-
web = base + self.classname + nodeid
531+
web = base + self.classname + issueid
532532

533533
# ensure the email address is properly quoted
534534
email = formataddr((self.db.config.TRACKER_NAME,
@@ -538,7 +538,7 @@ def email_signature(self, nodeid, msgid):
538538
return '\n%s\n%s\n<%s>\n%s'%(line, email, web, line)
539539

540540

541-
def generateCreateNote(self, nodeid):
541+
def generateCreateNote(self, issueid):
542542
"""Generate a create note that lists initial property values
543543
"""
544544
cn = self.classname
@@ -550,7 +550,7 @@ def generateCreateNote(self, nodeid):
550550
prop_items = props.items()
551551
prop_items.sort()
552552
for propname, prop in prop_items:
553-
value = cl.get(nodeid, propname, None)
553+
value = cl.get(issueid, propname, None)
554554
# skip boring entries
555555
if not value:
556556
continue
@@ -580,7 +580,7 @@ def generateCreateNote(self, nodeid):
580580
m.insert(0, '')
581581
return '\n'.join(m)
582582

583-
def generateChangeNote(self, nodeid, oldvalues):
583+
def generateChangeNote(self, issueid, oldvalues):
584584
"""Generate a change note that lists property changes
585585
"""
586586
if not isinstance(oldvalues, type({})):
@@ -601,7 +601,7 @@ def generateChangeNote(self, nodeid, oldvalues):
601601
# not all keys from oldvalues might be available in database
602602
# this happens when property was deleted
603603
try:
604-
new_value = cl.get(nodeid, key)
604+
new_value = cl.get(issueid, key)
605605
except KeyError:
606606
continue
607607
# the old value might be non existent
@@ -622,7 +622,7 @@ def generateChangeNote(self, nodeid, oldvalues):
622622
changed_items.sort()
623623
for propname, oldvalue in changed_items:
624624
prop = props[propname]
625-
value = cl.get(nodeid, propname, None)
625+
value = cl.get(issueid, propname, None)
626626
if isinstance(prop, hyperdb.Link):
627627
link = self.db.classes[prop.classname]
628628
key = link.labelprop(default_to_id=1)

test/memorydb.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@
1616
from roundup.hyperdb import *
1717
from roundup.support import ensureParentsExist
1818

19-
def new_config():
19+
def new_config(debug=False):
2020
config = configuration.CoreConfig()
2121
config.DATABASE = "db"
2222
#config.logging = MockNull()
2323
# these TRACKER_WEB and MAIL_DOMAIN values are used in mailgw tests
24+
if debug:
25+
config.LOGGING_LEVEL = "DEBUG"
2426
config.MAIL_DOMAIN = "your.tracker.email.domain.example"
2527
config.TRACKER_WEB = "http://tracker.example/cgi-bin/roundup.cgi/bugs/"
2628
return config
2729

28-
def create(journaltag, create=True):
29-
db = Database(new_config(), journaltag)
30+
def create(journaltag, create=True, debug=False):
31+
db = Database(new_config(debug), journaltag)
3032

3133
# load standard schema
3234
schema = os.path.join(os.path.dirname(__file__),

test/test_mailgw.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,49 @@ def testFollowup(self):
581581
Roundup issue tracker <[email protected]>
582582
<http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
583583
_______________________________________________________________________
584+
''')
585+
586+
def testNosyGeneration(self):
587+
self.db.issue.create(title='test')
588+
589+
# create a nosy message
590+
msg = self.db.msg.create(content='This is a test',
591+
author=self.richard_id, messageid='<dummy_test_message_id>')
592+
self.db.journaltag = 'richard'
593+
l = self.db.issue.create(title='test', messages=[msg],
594+
nosy=[self.chef_id, self.mary_id, self.john_id])
595+
596+
self.compareMessages(self._get_mail(),
597+
598+
599+
Content-Type: text/plain; charset="utf-8"
600+
Subject: [issue2] test
601+
602+
From: richard <[email protected]>
603+
Reply-To: Roundup issue tracker
604+
605+
MIME-Version: 1.0
606+
Message-Id: <dummy_test_message_id>
607+
X-Roundup-Name: Roundup issue tracker
608+
X-Roundup-Loop: hello
609+
X-Roundup-Issue-Status: unread
610+
Content-Transfer-Encoding: quoted-printable
611+
612+
613+
New submission from richard <[email protected]>:
614+
615+
This is a test
616+
617+
----------
618+
messages: 1
619+
nosy: Chef, john, mary, richard
620+
status: unread
621+
title: test
622+
623+
_______________________________________________________________________
624+
Roundup issue tracker <[email protected]>
625+
<http://tracker.example/cgi-bin/roundup.cgi/bugs/issue2>
626+
_______________________________________________________________________
584627
''')
585628

586629
def testPropertyChangeOnly(self):
@@ -615,6 +658,7 @@ def testPropertyChangeOnly(self):
615658
X-Roundup-Loop: hello
616659
X-Roundup-Issue-Status: unread
617660
X-Roundup-Version: 1.3.3
661+
In-Reply-To: <dummy_test_message_id>
618662
MIME-Version: 1.0
619663
Reply-To: Roundup issue tracker
620664
@@ -1935,7 +1979,7 @@ def testSecurityMessagePermissionContent(self):
19351979
charset="iso-8859-1"
19361980
From: Chef <[email protected]>
19371981
1938-
Message-Id: <dummy_test_message_id>
1982+
Message-Id: <dummy_test_message_id_2>
19391983
Subject: [issue%(id)s] Testing... [nosy=+mary]
19401984
19411985
Just a test reply
@@ -1951,7 +1995,8 @@ def testSecurityMessagePermissionContent(self):
19511995
Reply-To: Roundup issue tracker
19521996
19531997
MIME-Version: 1.0
1954-
Message-Id: <dummy_test_message_id>
1998+
Message-Id: <dummy_test_message_id_2>
1999+
In-Reply-To: <dummy_test_message_id>
19552000
X-Roundup-Name: Roundup issue tracker
19562001
X-Roundup-Loop: hello
19572002
X-Roundup-Issue-Status: chatting

0 commit comments

Comments
 (0)