Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits: 36b3a535 by Mark Sapiro at 2021-04-08T17:24:43-07:00 Remove the pending 'held message' when handling a held post. - - - - - 58f39d37 by Mark Sapiro at 2021-04-09T02:15:55+00:00 Merge branch 'handle' into 'master' Remove the pending 'held message' when handling a held post. Closes #257 See merge request mailman/mailman!820 - - - - - 3 changed files: - src/mailman/app/moderator.py - src/mailman/app/tests/test_moderation.py - src/mailman/docs/NEWS.rst Changes: ===================================== src/mailman/app/moderator.py ===================================== @@ -30,6 +30,7 @@ from mailman.interfaces.action import Action from mailman.interfaces.listmanager import ListDeletingEvent from mailman.interfaces.member import NotAMemberError from mailman.interfaces.messages import IMessageStore +from mailman.interfaces.pending import IPendings from mailman.interfaces.requests import IListRequests, RequestType from mailman.interfaces.template import ITemplateLoader from mailman.utilities.datetime import now @@ -170,6 +171,16 @@ def handle_message(mlist, id, action, comment=None, forward=None): fmsg.send(mlist) # Delete the request and message if it's not being kept. if not keep: + # There are two pended tokens. The request id has the moderator + # token, but wee need to delete the user token too. + user_token = None + pendings = getUtility(IPendings) + for token, data in pendings.find(pend_type='held message'): + if data['id'] == id: + user_token = token + break + if user_token is not None: + pendings.confirm(user_token, expunge=True) requestdb.delete_request(id) message_store.delete_message(message_id) # Log the rejection ===================================== src/mailman/app/tests/test_moderation.py ===================================== @@ -22,6 +22,7 @@ import unittest from mailman.app.lifecycle import create_list from mailman.app.moderator import ( handle_message, handle_unsubscription, hold_message, hold_unsubscription) +from mailman.chains.hold import HeldMessagePendable from mailman.interfaces.action import Action from mailman.interfaces.member import MemberRole from mailman.interfaces.messages import IMessageStore @@ -150,6 +151,20 @@ Message-ID: <alpha> self.assertIsNone(message) self.assertIsNone(getUtility(IPendings).confirm(hash)) + def test_all_pendings_removed(self): + # A held message pends two tokens, One for the moderator and one for + # the user. Ensure both are removed when meddage is handled. + request_id = hold_message(self._mlist, self._msg) + # The hold chain does more. + pendings = getUtility(IPendings) + user_hash = pendings.add(HeldMessagePendable(id=request_id)) + # Get the hash for this pending request. + hash = list(self._request_db.held_requests)[0].data_hash + handle_message(self._mlist, request_id, Action.discard) + self.assertEqual(self._request_db.count, 0) + self.assertIsNone(pendings.confirm(hash)) + self.assertIsNone(pendings.confirm(user_hash)) + class TestUnsubscription(unittest.TestCase): """Test unsubscription requests.""" ===================================== src/mailman/docs/NEWS.rst ===================================== @@ -25,6 +25,8 @@ Bugs * Admin notices sent when a list member's delivery is disabled by bounce or when a member's bounce score is incremented, now contain a copy of the triggering DSN. (Closes #737) +* Handling a held message now also removes the poster's pending + ``held message`` from the pending db. (Closes #257) REST ---- View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/d47128f11a20daeb4a8b488024f197379c3b9aeb...58f39d373e49743d41f06cd9a2aebe4bebb62b72 -- View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/d47128f11a20daeb4a8b488024f197379c3b9aeb...58f39d373e49743d41f06cd9a2aebe4bebb62b72 You're receiving this email because of your account on gitlab.com.
_______________________________________________ Mailman-checkins mailing list -- mailman-checkins@python.org To unsubscribe send an email to mailman-checkins-le...@python.org https://mail.python.org/mailman3/lists/mailman-checkins.python.org/ Member address: arch...@jab.org