Skip to content

Commit 7b4d329

Browse files
author
Johannes Gijsbers
committed
Don't rely on being about an issue...
...when submitting a message to the mail gateway.
1 parent df93876 commit 7b4d329

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

roundup/mailgw.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class node. Any parts of other types are each stored in separate files
7373
an exception, the original message is bounced back to the sender with the
7474
explanatory message given in the exception.
7575
76-
$Id: mailgw.py,v 1.135 2003-10-25 12:03:41 jlgijsbers Exp $
76+
$Id: mailgw.py,v 1.136 2003-11-03 18:34:03 jlgijsbers Exp $
7777
"""
7878

7979
import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
@@ -789,27 +789,27 @@ def handle_message(self, message):
789789
#
790790
# handle the attachments
791791
#
792-
files = []
793-
for (name, mime_type, data) in attachments:
794-
if not name:
795-
name = "unnamed"
796-
files.append(self.db.file.create(type=mime_type, name=name,
797-
content=data, **file_props))
798-
# attach the files to the issue
799-
if nodeid:
800-
# extend the existing files list
801-
fileprop = cl.get(nodeid, 'files')
802-
fileprop.extend(files)
803-
props['files'] = fileprop
804-
else:
805-
# pre-load the files list
806-
props['files'] = files
807-
792+
if properties.has_key('files'):
793+
files = []
794+
for (name, mime_type, data) in attachments:
795+
if not name:
796+
name = "unnamed"
797+
files.append(self.db.file.create(type=mime_type, name=name,
798+
content=data, **file_props))
799+
# attach the files to the issue
800+
if nodeid:
801+
# extend the existing files list
802+
fileprop = cl.get(nodeid, 'files')
803+
fileprop.extend(files)
804+
props['files'] = fileprop
805+
else:
806+
# pre-load the files list
807+
props['files'] = files
808808

809809
#
810810
# create the message if there's a message body (content)
811811
#
812-
if content:
812+
if (content and properties.has_key('messages')):
813813
message_id = self.db.msg.create(author=author,
814814
recipients=recipients, date=date.Date('.'), summary=summary,
815815
content=content, files=files, messageid=messageid,

test/test_mailgw.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# but WITHOUT ANY WARRANTY; without even the implied warranty of
99
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010
#
11-
# $Id: test_mailgw.py,v 1.57 2003-10-25 22:53:26 richard Exp $
11+
# $Id: test_mailgw.py,v 1.58 2003-11-03 18:34:03 jlgijsbers Exp $
1212

1313
import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822
1414

@@ -997,6 +997,23 @@ def testRegistrationConfirmation(self):
997997

998998
self.db.user.lookup('johannes')
999999

1000+
def testFollowupOnNonIssue(self):
1001+
self.db.keyword.create(name='Foo')
1002+
message = StringIO('''Content-Type: text/plain;
1003+
charset="iso-8859-1"
1004+
From: richard <richard@test>
1005+
1006+
Message-Id: <followup_dummy_id>
1007+
In-Reply-To: <dummy_test_message_id>
1008+
Subject: [keyword1] Testing... [name=Bar]
1009+
1010+
''')
1011+
handler = self.instance.MailGW(self.instance, self.db)
1012+
handler.trapExceptions = 0
1013+
handler.main(message)
1014+
1015+
self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar')
1016+
10001017
def test_suite():
10011018
suite = unittest.TestSuite()
10021019
suite.addTest(unittest.makeSuite(MailgwTestCase))

0 commit comments

Comments
 (0)