Skip to content

Commit eb792b2

Browse files
author
Ralf Schlatterbeck
committed
Add config-option "nosy" to messages_to_author setting in [nosy] section...
...of config: This will send a message to the author only in the case where the author is on the nosy-list (either added earlier or via the add_author setting). Current config-options for this setting will send / not send to author without considering the nosy list. [[Posted on behalf of Dr. Schlatterbeck during the git conversion.]] committer: Eric S. Raymond <[email protected]>
1 parent eea24e6 commit eb792b2

File tree

4 files changed

+148
-34
lines changed

4 files changed

+148
-34
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ Features:
1515
translation as it used to be (Ralf)
1616
- Sending of PGP-Encrypted mail to all users or selected users (via
1717
roles) is now working. (Ralf)
18+
- Add config-option "nosy" to messages_to_author setting in [nosy]
19+
section of config: This will send a message to the author only
20+
in the case where the author is on the nosy-list (either added
21+
earlier or via the add_author setting). Current config-options
22+
for this setting will send / not send to author without considering
23+
the nosy list. (Ralf)
1824

1925
Fixed:
2026

roundup/configuration.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,12 @@ def str2value(self, value):
831831
"turned on."),
832832
), "OpenPGP mail processing options"),
833833
("nosy", (
834-
(RunDetectorOption, "messages_to_author", "no",
835-
"Send nosy messages to the author of the message.",
834+
(Option, "messages_to_author", "no",
835+
"Send nosy messages to the author of the message.\n"
836+
"Allowed values: yes, no, new, nosy -- if yes, messages\n"
837+
"are sent to the author even if not on the nosy list, same\n"
838+
"for new (but only for new messages). When set to nosy,\n"
839+
"the nosy list controls sending messages to the author.",
836840
["MESSAGES_TO_AUTHOR"]),
837841
(Option, "signature_position", "bottom",
838842
"Where to place the email signature.\n"

roundup/roundupdb.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ def good_recipient(userid):
285285
# anonymous
286286
if (good_recipient(authid) and
287287
(self.db.config.MESSAGES_TO_AUTHOR == 'yes' or
288-
(self.db.config.MESSAGES_TO_AUTHOR == 'new' and not oldvalues))):
288+
(self.db.config.MESSAGES_TO_AUTHOR == 'new' and not oldvalues) or
289+
(self.db.config.MESSAGES_TO_AUTHOR == 'nosy' and authid in
290+
self.get(issueid, whichnosy)))):
289291
add_recipient(authid, sendto)
290292

291293
if authid:

test/test_mailgw.py

Lines changed: 133 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,7 @@ def testOptionClass(self):
290290
self.assertEqual(self.db.issue.get(nodeid, 'status'), '3')
291291
self.assertEqual(self.db.issue.get(nodeid, 'priority'), '1')
292292

293-
def doNewIssue(self):
294-
nodeid = self._handle_mail('''Content-Type: text/plain;
293+
newmsg = '''Content-Type: text/plain;
295294
charset="iso-8859-1"
296295
From: Chef <[email protected]>
297296
@@ -300,7 +299,10 @@ def doNewIssue(self):
300299
Subject: [issue] Testing...
301300
302301
This is a test submission of a new issue.
303-
''')
302+
'''
303+
304+
def doNewIssue(self):
305+
nodeid = self._handle_mail(self.newmsg)
304306
assert not os.path.exists(SENDMAILDEBUG)
305307
l = self.db.issue.get(nodeid, 'nosy')
306308
l.sort()
@@ -312,20 +314,25 @@ def testNewIssue(self):
312314

313315
def testNewIssueNosy(self):
314316
self.instance.config.ADD_AUTHOR_TO_NOSY = 'yes'
315-
nodeid = self._handle_mail('''Content-Type: text/plain;
316-
charset="iso-8859-1"
317-
From: Chef <[email protected]>
318-
319-
320-
Message-Id: <dummy_test_message_id>
321-
Subject: [issue] Testing...
317+
nodeid = self.doNewIssue()
318+
m = self.db.issue.get(nodeid, 'messages')
319+
self.assertEqual(len(m), 1)
320+
recv = self.db.msg.get(m[0], 'recipients')
321+
self.assertEqual(recv, [self.richard_id])
322322

323-
This is a test submission of a new issue.
324-
''')
323+
def testNewIssueNosyAuthor(self):
324+
self.instance.config.ADD_AUTHOR_TO_NOSY = 'no'
325+
self.instance.config.MESSAGES_TO_AUTHOR = 'nosy'
326+
nodeid = self._handle_mail(self.newmsg)
325327
assert not os.path.exists(SENDMAILDEBUG)
326328
l = self.db.issue.get(nodeid, 'nosy')
327329
l.sort()
328-
self.assertEqual(l, [self.chef_id, self.richard_id])
330+
self.assertEqual(l, [self.richard_id])
331+
m = self.db.issue.get(nodeid, 'messages')
332+
self.assertEqual(len(m), 1)
333+
recv = self.db.msg.get(m[0], 'recipients')
334+
recv.sort()
335+
self.assertEqual(recv, [self.richard_id])
329336

330337
def testAlternateAddress(self):
331338
self._handle_mail('''Content-Type: text/plain;
@@ -356,7 +363,6 @@ def testNewIssueNoClass(self):
356363
assert not os.path.exists(SENDMAILDEBUG)
357364

358365
def testNewIssueAuthMsg(self):
359-
# TODO: fix the damn config - this is apalling
360366
self.db.config.MESSAGES_TO_AUTHOR = 'yes'
361367
self._handle_mail('''Content-Type: text/plain;
362368
charset="iso-8859-1"
@@ -1453,11 +1459,7 @@ def testFollowupTitleMatchInterval(self):
14531459
This is a followup
14541460
'''), nodeid)
14551461

1456-
1457-
def testFollowupNosyAuthor(self):
1458-
self.doNewIssue()
1459-
self.db.config.ADD_AUTHOR_TO_NOSY = 'yes'
1460-
self._handle_mail('''Content-Type: text/plain;
1462+
simple_followup = '''Content-Type: text/plain;
14611463
charset="iso-8859-1"
14621464
14631465
@@ -1466,8 +1468,12 @@ def testFollowupNosyAuthor(self):
14661468
Subject: [issue1] Testing...
14671469
14681470
This is a followup
1469-
''')
1471+
'''
14701472

1473+
def testFollowupNosyAuthor(self):
1474+
self.doNewIssue()
1475+
self.db.config.ADD_AUTHOR_TO_NOSY = 'yes'
1476+
self._handle_mail(self.simple_followup)
14711477
self.compareMessages(self._get_mail(),
14721478
14731479
@@ -1505,7 +1511,7 @@ def testFollowupNosyRecipients(self):
15051511
self.doNewIssue()
15061512
self.db.config.ADD_RECIPIENTS_TO_NOSY = 'yes'
15071513
self._handle_mail('''Content-Type: text/plain;
1508-
charset="iso-8859-1"
1514+
charset="iso-8859-1"
15091515
15101516
15111517
@@ -1552,16 +1558,45 @@ def testFollowupNosyAuthorAndCopy(self):
15521558
self.doNewIssue()
15531559
self.db.config.ADD_AUTHOR_TO_NOSY = 'yes'
15541560
self.db.config.MESSAGES_TO_AUTHOR = 'yes'
1555-
self._handle_mail('''Content-Type: text/plain;
1556-
charset="iso-8859-1"
1557-
1558-
1561+
self._handle_mail(self.simple_followup)
1562+
self.compareMessages(self._get_mail(),
1563+
1564+
1565+
Content-Type: text/plain; charset="utf-8"
1566+
Subject: [issue1] Testing...
1567+
1568+
From: John Doe <[email protected]>
1569+
Reply-To: Roundup issue tracker
1570+
1571+
MIME-Version: 1.0
15591572
Message-Id: <followup_dummy_id>
15601573
In-Reply-To: <dummy_test_message_id>
1561-
Subject: [issue1] Testing...
1574+
X-Roundup-Name: Roundup issue tracker
1575+
X-Roundup-Loop: hello
1576+
X-Roundup-Issue-Status: chatting
1577+
Content-Transfer-Encoding: quoted-printable
1578+
1579+
1580+
John Doe <[email protected]> added the comment:
15621581
15631582
This is a followup
1583+
1584+
----------
1585+
nosy: +john
1586+
status: unread -> chatting
1587+
1588+
_______________________________________________________________________
1589+
Roundup issue tracker <[email protected]>
1590+
<http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
1591+
_______________________________________________________________________
1592+
15641593
''')
1594+
1595+
def testFollowupNosyAuthorNosyCopy(self):
1596+
self.doNewIssue()
1597+
self.db.config.ADD_AUTHOR_TO_NOSY = 'yes'
1598+
self.db.config.MESSAGES_TO_AUTHOR = 'nosy'
1599+
self._handle_mail(self.simple_followup)
15651600
self.compareMessages(self._get_mail(),
15661601
15671602
@@ -1598,16 +1633,44 @@ def testFollowupNosyAuthorAndCopy(self):
15981633
def testFollowupNoNosyAuthor(self):
15991634
self.doNewIssue()
16001635
self.instance.config.ADD_AUTHOR_TO_NOSY = 'no'
1601-
self._handle_mail('''Content-Type: text/plain;
1602-
charset="iso-8859-1"
1603-
1604-
1636+
self._handle_mail(self.simple_followup)
1637+
self.compareMessages(self._get_mail(),
1638+
1639+
1640+
Content-Type: text/plain; charset="utf-8"
1641+
Subject: [issue1] Testing...
1642+
1643+
From: John Doe <[email protected]>
1644+
Reply-To: Roundup issue tracker
1645+
1646+
MIME-Version: 1.0
16051647
Message-Id: <followup_dummy_id>
16061648
In-Reply-To: <dummy_test_message_id>
1607-
Subject: [issue1] Testing...
1649+
X-Roundup-Name: Roundup issue tracker
1650+
X-Roundup-Loop: hello
1651+
X-Roundup-Issue-Status: chatting
1652+
Content-Transfer-Encoding: quoted-printable
1653+
1654+
1655+
John Doe <[email protected]> added the comment:
16081656
16091657
This is a followup
1658+
1659+
----------
1660+
status: unread -> chatting
1661+
1662+
_______________________________________________________________________
1663+
Roundup issue tracker <[email protected]>
1664+
<http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
1665+
_______________________________________________________________________
1666+
16101667
''')
1668+
1669+
def testFollowupNoNosyAuthorNoCopy(self):
1670+
self.doNewIssue()
1671+
self.instance.config.ADD_AUTHOR_TO_NOSY = 'no'
1672+
self.instance.config.MESSAGES_TO_AUTHOR = 'nosy'
1673+
self._handle_mail(self.simple_followup)
16111674
self.compareMessages(self._get_mail(),
16121675
16131676
@@ -1626,6 +1689,45 @@ def testFollowupNoNosyAuthor(self):
16261689
Content-Transfer-Encoding: quoted-printable
16271690
16281691
1692+
John Doe <[email protected]> added the comment:
1693+
1694+
This is a followup
1695+
1696+
----------
1697+
status: unread -> chatting
1698+
1699+
_______________________________________________________________________
1700+
Roundup issue tracker <[email protected]>
1701+
<http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
1702+
_______________________________________________________________________
1703+
1704+
''')
1705+
1706+
# this is a pathological case where the author is *not* on the nosy
1707+
# list but gets the message; test documents existing behaviour
1708+
def testFollowupNoNosyAuthorButCopy(self):
1709+
self.doNewIssue()
1710+
self.instance.config.ADD_AUTHOR_TO_NOSY = 'no'
1711+
self.instance.config.MESSAGES_TO_AUTHOR = 'yes'
1712+
self._handle_mail(self.simple_followup)
1713+
self.compareMessages(self._get_mail(),
1714+
1715+
1716+
Content-Type: text/plain; charset="utf-8"
1717+
Subject: [issue1] Testing...
1718+
1719+
From: John Doe <[email protected]>
1720+
Reply-To: Roundup issue tracker
1721+
1722+
MIME-Version: 1.0
1723+
Message-Id: <followup_dummy_id>
1724+
In-Reply-To: <dummy_test_message_id>
1725+
X-Roundup-Name: Roundup issue tracker
1726+
X-Roundup-Loop: hello
1727+
X-Roundup-Issue-Status: chatting
1728+
Content-Transfer-Encoding: quoted-printable
1729+
1730+
16291731
John Doe <[email protected]> added the comment:
16301732
16311733
This is a followup

0 commit comments

Comments
 (0)