Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
cf4aa05f by Mark Sapiro at 2022-07-30T03:08:45+00:00
Implement the verp_confirmations setting with default of yes.

Fixes #1023

- - - - -
3e49d586 by Mark Sapiro at 2022-07-30T03:08:45+00:00
Merge branch 'verp' into 'master'

Implement the verp_confirmations setting with default of yes.

Closes #1023

See merge request mailman/mailman!1028
- - - - -


4 changed files:

- src/mailman/app/subscriptions.py
- src/mailman/app/tests/test_subscriptions.py
- src/mailman/config/schema.cfg
- src/mailman/docs/NEWS.rst


Changes:

=====================================
src/mailman/app/subscriptions.py
=====================================
@@ -22,8 +22,10 @@ import logging
 
 from email.utils import formataddr
 from enum import Enum
+from lazr.config import as_boolean
 from mailman.app.membership import delete_member
 from mailman.app.workflow import Workflow
+from mailman.config import config
 from mailman.core.i18n import _
 from mailman.database.transaction import flush
 from mailman.email.message import UserNotification
@@ -647,6 +649,10 @@ def _handle_confirmation_needed_events(event, 
template_name):
         domain_name=event.mlist.domain.mail_host,
         contact_address=event.mlist.owner_address,
         ))
+    if ('verp_confirmations' in config.mta and not
+            as_boolean(config.mta.verp_confirmations)):
+        subject = 'confirm {}'.format(event.token)
+        confirm_address = event.mlist.request_address
     msg = UserNotification(
         email_address, confirm_address, subject, text,
         event.mlist.preferred_language)


=====================================
src/mailman/app/tests/test_subscriptions.py
=====================================
@@ -41,6 +41,7 @@ from mailman.interfaces.pending import IPendings
 from mailman.interfaces.subscriptions import ISubscriptionManager, TokenOwner
 from mailman.interfaces.usermanager import IUserManager
 from mailman.testing.helpers import (
+    configuration,
     get_queue_messages,
     LogFileMark,
     set_preferred,
@@ -634,6 +635,21 @@ approval:
         # one token still in the database.
         self._expected_pendings_count = 1
 
+    def test_invitation_verp_confirmations_no(self):
+        # Test From: and Subject: with verp_confirmations equal no.
+        anne = self._user_manager.create_address(self._anne)
+        self.assertIsNone(anne.verified_on)
+        # Run the workflow to model the confirmation step.
+        workflow = SubscriptionWorkflow(self._mlist, anne, invitation=True)
+        with configuration('mta', verp_confirmations='no'):
+            list(workflow)
+        items = get_queue_messages('virgin', expected_count=1)
+        message = items[0].msg
+        token = workflow.token
+        self.assertEqual(f'confirm {token}', str(message['Subject']))
+        self.assertEqual('test-requ...@example.com', message['From'])
+        self._expected_pendings_count = 1
+
     def test_send_confirmation_pre_confirmed(self):
         # A confirmation message gets sent when the address is not verified
         # but the subscription is pre-confirmed.
@@ -654,6 +670,21 @@ approval:
         # one token still in the database.
         self._expected_pendings_count = 1
 
+    def test_confirmation_subscribe_verp_confirmations_no(self):
+        # Test From: and Subject: with verp_confirmations equal no.
+        anne = self._user_manager.create_address(self._anne)
+        self.assertIsNone(anne.verified_on)
+        # Run the workflow to model the confirmation step.
+        workflow = SubscriptionWorkflow(self._mlist, anne, pre_confirmed=True)
+        with configuration('mta', verp_confirmations='no'):
+            list(workflow)
+        items = get_queue_messages('virgin', expected_count=1)
+        message = items[0].msg
+        token = workflow.token
+        self.assertEqual(f'confirm {token}', str(message['Subject']))
+        self.assertEqual('test-requ...@example.com', message['From'])
+        self._expected_pendings_count = 1
+
     def test_send_confirmation_pre_verified(self):
         # A confirmation message gets sent even when the address is verified
         # when the subscription must be confirmed.


=====================================
src/mailman/config/schema.cfg
=====================================
@@ -873,6 +873,10 @@ verp_regexp: 
^(?P<bounces>[^+]+?)\+(?P<local>[^=]+)=(?P<domain>[^@]+)@.*$
 # when replying, so we skip everything up to '<' if any.
 verp_confirm_regexp: ^(.*<)?(?P<addr>[^+]+?)\+(?P<cookie>[^@]+)@.*$
 
+# Set this to 'no' to disable user friendly confirmations and avoid encoding
+# the confirmation cookie in the reply address.
+verp_confirmations: yes
+
 # Another good opportunity is when regular delivery is personalized.  Here
 # again, we're already incurring the performance hit for addressing each
 # individual recipient.  Set this to 'yes' to enable VERPs on all personalized


=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -69,6 +69,8 @@ Bugs fixed
   parts of folded subject headers.  (Closes #1021)
 * Outgoing messages are now flattened using the as_bytes() method for better
   RFC compliance.  (Closes #1022)
+* The ``verp_confirmations`` setting has now been implemented with default
+  of ``yes``.  (Closes #1023)
 
 REST
 ====



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/a6e6f80dfa8386879df2c837064c8340f23fbd8f...3e49d586cef1eaaf030084d1dea1066c7dc43054

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/a6e6f80dfa8386879df2c837064c8340f23fbd8f...3e49d586cef1eaaf030084d1dea1066c7dc43054
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

Reply via email to