Commit 8071d4a2 authored by Aurélien Bompard's avatar Aurélien Bompard

Don't assume the list-id from the list fqdn

Fixes: #428
parent 31f434d0
......@@ -40,6 +40,7 @@ Bugs
subaddresses can now be posted to. (Closes #433)
* The ``admin`` subaddress, a synonym for ``bounces`` and deprecated since
Mailman 2.1, has been removed. (Closes #435)
* Better support for changing the ``list_name`` property. (Closes #428)
Command line
......@@ -74,8 +74,8 @@ class ListManager:
def get_by_fqdn(self, store, fqdn_listname):
"""See `IListManager`."""
listname, at, hostname = fqdn_listname.partition('@')
list_id = '{}.{}'.format(listname, hostname)
return store.query(MailingList).filter_by(_list_id=list_id).first()
return store.query(MailingList).filter_by(
list_name=listname, mail_host=hostname).first()
def delete(self, store, mlist):
......@@ -153,6 +153,15 @@ class TestListManager(unittest.TestCase):
self.assertEqual(list_manager.get_by_fqdn(''), ant)
def test_find_by_fqdn_renamed(self):
ant = create_list('')
ant.list_name = 'renamed'
self.assertEqual(ant.posting_address, '')
self.assertEqual(ant.list_id, '')
list_manager = getUtility(IListManager)
self.assertEqual(list_manager.get_by_fqdn(''), ant)
class TestListLifecycleEvents(unittest.TestCase):
layer = ConfigLayer
......@@ -165,12 +165,12 @@ class LMTPHandler:
if listname not in listnames:
listid = '{}.{}'.format(local, domain)
mlist = getUtility(IListManager).get_by_fqdn(listname)
# The recipient is a valid mailing list. Find the subaddress
# if there is one, and set things up to enqueue to the proper
# queue.
queue = None
msgdata = dict(listid=listid,
msgdata = dict(listid=mlist.list_id,
canonical_subaddress = SUBADDRESS_NAMES.get(subaddress)
......@@ -197,6 +197,24 @@ Subject: This will be recognized as a post to the -join list.
get_queue_messages('in', expected_count=1)
get_queue_messages('command', expected_count=0)
def test_mailing_list_with_different_address_and_list_id(self):
# A mailing list can be renamed, in which case the list_name
# will be different but the list_id will remain the same.
with transaction():
self._mlist.list_name = 'renamed'
self.assertEqual(self._mlist.posting_address, '')
self._lmtp.sendmail('', [''], """\
Message-ID: <ant>
Subject: This should be accepted.
# The message is in the incoming queue but not the command queue.
items = get_queue_messages('in', expected_count=1)
self.assertEqual(items[0].msgdata['listid'], '')
class TestBugs(unittest.TestCase):
"""Test some LMTP related bugs."""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment