Skip to content

Commit 714b4e8

Browse files
committed
issue2550957: Duplicate emails (with patch).
Bcc and cc users passed to nosymessage are not properly recorded. This results in duplicate emails. Patch by Trent Gamblin (trentgg). Applied by and test added by John Rouillard.
1 parent d690a37 commit 714b4e8

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,10 @@ Fixed:
476476
- issue2550953: Patch: fix for context.is_view_ok check in jinja2 template
477477
Form controls are displayed when anonymous views indexes but is
478478
denied access. (patch by Anton Schur applied by John Rouillard)
479+
- issue2550957: Duplicate emails (with patch).
480+
Bcc and cc users passed to nosymessage are not properly recorded.
481+
This results in duplicate emails. (patch by Trent Gamblin (trentgg)
482+
applied by John Rouillard).
479483

480484
2016-01-11: 1.5.1
481485

roundup/roundupdb.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ def good_recipient(userid):
330330
for userid in cc + self.get(issueid, whichnosy):
331331
if good_recipient(userid):
332332
add_recipient(userid, sendto)
333+
seen_message[userid] = 1
333334
if encrypt and not pgproles:
334335
sendto['crypt'].extend (cc_emails)
335336
else:
@@ -339,6 +340,7 @@ def good_recipient(userid):
339340
for userid in bcc:
340341
if good_recipient(userid):
341342
add_recipient(userid, bcc_sendto)
343+
seen_message[userid] = 1
342344
if encrypt and not pgproles:
343345
bcc_sendto['crypt'].extend (bcc_emails)
344346
else:

test/test_mailgw.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,101 @@ def testNosyGeneration(self):
17061706
_______________________________________________________________________
17071707
''')
17081708

1709+
def testNosyMessageCcBccEtc(self):
1710+
self.doNewIssue()
1711+
oldvalues = self.db.getnode('issue', '1').copy()
1712+
oldvalues['assignedto'] = None
1713+
# reconstruct old behaviour: This would reuse the
1714+
# database-handle from the doNewIssue above which has committed
1715+
# as user "Chef". So we close and reopen the db as that user.
1716+
#self.db.close() actually don't close 'cos this empties memorydb
1717+
self.db = self.instance.open('Chef')
1718+
self.db.issue.set('1', assignedto=self.chef_id)
1719+
self.db.commit()
1720+
# note user 3 is both in cc and bcc. The one in cc takes
1721+
# precedence and stops the bcc copy from being sent to user 3..
1722+
# new email is generated for bcc peoples: admin and kermit
1723+
# get it.
1724+
self.db.issue.nosymessage('1', None, oldvalues,
1725+
cc=['3','4', '5'], bcc=['1', '3', '5'],
1726+
cc_emails=['[email protected]'],
1727+
bcc_emails=["[email protected]"])
1728+
new_mail = ""
1729+
for line in self._get_mail().split("\n"):
1730+
if "Message-Id: " in line:
1731+
continue
1732+
if "Date: " in line:
1733+
continue
1734+
new_mail += line+"\n"
1735+
1736+
# new_mail is a mbox style string with 2 emails.
1737+
# we need to split the emails and compare.
1738+
new_mails=new_mail.split("\nFrom ")
1739+
# restore the "From " prefix removed from first line of
1740+
# second message by strip.
1741+
new_mails[1]="From " + new_mail.split("\nFrom ")[1]
1742+
1743+
self.compareMessages(new_mails[0], """
1744+
1745+
1746+
Content-Type: text/plain; charset="utf-8"
1747+
Subject: [issue1] Testing...
1748+
1749+
From: "Bork, Chef" <[email protected]>
1750+
X-Roundup-Name: Roundup issue tracker
1751+
X-Roundup-Loop: hello
1752+
X-Roundup-Issue-Status: unread
1753+
X-Roundup-Version: 1.3.3
1754+
In-Reply-To: <dummy_test_message_id>
1755+
MIME-Version: 1.0
1756+
Reply-To: Roundup issue tracker
1757+
1758+
Content-Transfer-Encoding: quoted-printable
1759+
1760+
1761+
Change by Bork, Chef <[email protected]>:
1762+
1763+
1764+
----------
1765+
assignedto: -> Chef
1766+
1767+
_______________________________________________________________________
1768+
Roundup issue tracker <[email protected]>
1769+
<http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
1770+
_______________________________________________________________________
1771+
""")
1772+
1773+
self.compareMessages(new_mails[1], """
1774+
1775+
1776+
Content-Type: text/plain; charset="utf-8"
1777+
Subject: [issue1] Testing...
1778+
1779+
From: "Bork, Chef" <[email protected]>
1780+
X-Roundup-Name: Roundup issue tracker
1781+
X-Roundup-Loop: hello
1782+
X-Roundup-Issue-Status: unread
1783+
X-Roundup-Version: 1.3.3
1784+
In-Reply-To: <dummy_test_message_id>
1785+
MIME-Version: 1.0
1786+
Reply-To: Roundup issue tracker
1787+
1788+
Content-Transfer-Encoding: quoted-printable
1789+
1790+
1791+
Change by Bork, Chef <[email protected]>:
1792+
1793+
1794+
----------
1795+
assignedto: -> Chef
1796+
1797+
_______________________________________________________________________
1798+
Roundup issue tracker <[email protected]>
1799+
<http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
1800+
_______________________________________________________________________
1801+
""")
1802+
1803+
17091804
def testPropertyChangeOnly(self):
17101805
self.doNewIssue()
17111806
oldvalues = self.db.getnode('issue', '1').copy()

0 commit comments

Comments
 (0)