From: jlgijsbers Date: Mon, 3 Nov 2003 18:34:03 +0000 (+0000) Subject: Don't rely on being about an issue when submitting a message to the X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c6e47885eb2d6fdd04e1e320dec0c796df6511a2;p=roundup.git Don't rely on being about an issue when submitting a message to the mail gateway. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1956 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/mailgw.py b/roundup/mailgw.py index 544ef29..ab03bda 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -73,7 +73,7 @@ are calling the create() method to create a new node). If an auditor raises an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.135 2003-10-25 12:03:41 jlgijsbers Exp $ +$Id: mailgw.py,v 1.136 2003-11-03 18:34:03 jlgijsbers Exp $ """ import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri @@ -789,27 +789,27 @@ not find a text/plain part to use. # # handle the attachments # - files = [] - for (name, mime_type, data) in attachments: - if not name: - name = "unnamed" - files.append(self.db.file.create(type=mime_type, name=name, - content=data, **file_props)) - # attach the files to the issue - if nodeid: - # extend the existing files list - fileprop = cl.get(nodeid, 'files') - fileprop.extend(files) - props['files'] = fileprop - else: - # pre-load the files list - props['files'] = files - + if properties.has_key('files'): + files = [] + for (name, mime_type, data) in attachments: + if not name: + name = "unnamed" + files.append(self.db.file.create(type=mime_type, name=name, + content=data, **file_props)) + # attach the files to the issue + if nodeid: + # extend the existing files list + fileprop = cl.get(nodeid, 'files') + fileprop.extend(files) + props['files'] = fileprop + else: + # pre-load the files list + props['files'] = files # # create the message if there's a message body (content) # - if content: + if (content and properties.has_key('messages')): message_id = self.db.msg.create(author=author, recipients=recipients, date=date.Date('.'), summary=summary, content=content, files=files, messageid=messageid, diff --git a/test/test_mailgw.py b/test/test_mailgw.py index ea5adde..137d7a2 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -8,7 +8,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: test_mailgw.py,v 1.57 2003-10-25 22:53:26 richard Exp $ +# $Id: test_mailgw.py,v 1.58 2003-11-03 18:34:03 jlgijsbers Exp $ import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 @@ -997,6 +997,23 @@ This is a test confirmation of registration. self.db.user.lookup('johannes') + def testFollowupOnNonIssue(self): + self.db.keyword.create(name='Foo') + message = StringIO('''Content-Type: text/plain; + charset="iso-8859-1" +From: richard +To: issue_tracker@your.tracker.email.domain.example +Message-Id: +In-Reply-To: +Subject: [keyword1] Testing... [name=Bar] + +''') + handler = self.instance.MailGW(self.instance, self.db) + handler.trapExceptions = 0 + handler.main(message) + + self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar') + def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(MailgwTestCase))