Abhilash Raj pushed to branch master at GNU Mailman / Mailman Core
Commits: 90807312 by Mark Sapiro at 2019-09-23T00:47:56Z Allow adding the list posting address with nonmember role. - - - - - ce48dc8b by Abhilash Raj at 2019-09-23T00:47:57Z Merge branch 'fix_633' into 'master' Allow adding the list posting address with nonmember role. Closes #633 See merge request mailman/mailman!557 - - - - - 4 changed files: - src/mailman/app/membership.py - src/mailman/app/tests/test_membership.py - src/mailman/docs/NEWS.rst - src/mailman/model/mailinglist.py Changes: ===================================== src/mailman/app/membership.py ===================================== @@ -60,8 +60,9 @@ def add_member(mlist, record, role=MemberRole.member): # Check to see if the email address is banned. if IBanManager(mlist).is_banned(record.email): raise MembershipIsBannedError(mlist, record.email) - # Check for list posting address. - if record.email.lower() == mlist.posting_address: + # Check for list posting address, but allow for nonmember. + if (record.email.lower() == mlist.posting_address and + role != MemberRole.nonmember): raise InvalidEmailAddressError('List posting address not allowed') # Make sure there is a user linked with the given address. user_manager = getUtility(IUserManager) ===================================== src/mailman/app/tests/test_membership.py ===================================== @@ -120,14 +120,15 @@ class TestAddMember(unittest.TestCase): MemberRole.owner) def test_add_posting_address_nonmember(self): - # Test that we can't add the list posting address. - self.assertRaises( - InvalidEmailAddressError, - add_member, self._mlist, - RequestRecord(self._mlist.posting_address, 'The List', - DeliveryMode.regular, - system_preferences.preferred_language), - MemberRole.nonmember) + # Test that we can add the list posting address as a nonmember. + request_record = RequestRecord(self._mlist.posting_address, + 'The List', + DeliveryMode.regular, + system_preferences.preferred_language) + member = add_member(self._mlist, request_record, MemberRole.nonmember) + self.assertEqual(member.address.email, self._mlist.posting_address) + self.assertEqual(member.list_id, 'test.example.com') + self.assertEqual(member.role, MemberRole.nonmember) def test_add_member_banned_from_different_list(self): # Test that members who are banned by on a different list can still be ===================================== src/mailman/docs/NEWS.rst ===================================== @@ -13,7 +13,10 @@ Here is a history of user visible changes to Mailman. (2019-XX-XX) - +Bugs +---- +* It is now possible to add the list posting address with nonmember role, e.g. + to give it a moderaction of discard. (Closes #633) 3.3.0 -- "Tom Sawyer" ===================== ===================================== src/mailman/model/mailinglist.py ===================================== @@ -487,7 +487,9 @@ class MailingList(Model): """See `IMailingList`.""" member, email = self._get_subscriber(store, subscriber, role) test_email = email or subscriber.lower() - if test_email == self.posting_address: + # Allow list posting address only for nonmember role. + if (test_email == self.posting_address and + role != MemberRole.nonmember): raise InvalidEmailAddressError('List posting address not allowed') if member is not None: raise AlreadySubscribedError(self.fqdn_listname, email, role) View it on GitLab: https://gitlab.com/mailman/mailman/compare/6e5b4f84142cfa680cae7c8ec7c2068672179474...ce48dc8bbdf75edad74a8114cf7f5dcf452d8e39 -- View it on GitLab: https://gitlab.com/mailman/mailman/compare/6e5b4f84142cfa680cae7c8ec7c2068672179474...ce48dc8bbdf75edad74a8114cf7f5dcf452d8e39 You're receiving this email because of your account on gitlab.com.
_______________________________________________ Mailman-checkins mailing list Mailman-checkins@python.org Unsubscribe: https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org