Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits: aa6db0a5 by Mark Sapiro at 2021-11-30T21:10:39+00:00 Add list context an a few more replacements to expansion of goodbye template. - - - - - b5c15e4d by Mark Sapiro at 2021-11-30T21:10:39+00:00 Merge branch 'goodbye' into 'master' Add list context an a few more replacements to expansion of goodbye template. See merge request mailman/mailman!939 - - - - - 3 changed files: - src/mailman/app/notifications.py - src/mailman/app/tests/test_notifications.py - src/mailman/docs/NEWS.rst Changes: ===================================== src/mailman/app/notifications.py ===================================== @@ -116,7 +116,15 @@ def send_goodbye_message(mlist, address, language): :type language: ILanguage """ goodbye_message = wrap(expand(getUtility(ITemplateLoader).get( - 'list:user:notice:goodbye', mlist, language=language.code))) + 'list:user:notice:goodbye', mlist, language=language.code), + mlist, dict( + user_email=address, + # For backward compatibility. + user_address=address, + fqdn_listname=mlist.fqdn_listname, + list_name=mlist.display_name, + list_requests=mlist.request_address, + ))) msg = UserNotification( address, mlist.bounces_address, _('You have been unsubscribed from the $mlist.display_name ' ===================================== src/mailman/app/tests/test_notifications.py ===================================== @@ -24,6 +24,7 @@ import unittest from contextlib import ExitStack from mailman.app.lifecycle import create_list +from mailman.app.notifications import send_goodbye_message from mailman.config import config from mailman.interfaces.languages import ILanguageManager from mailman.interfaces.member import MemberRole @@ -70,6 +71,11 @@ Welcome to the $list_name mailing list. Help and other requests: $list_requests Your name: $user_name Your address: $user_address""", file=fp) + # Write a goodbye message. + full_path = os.path.join(path, 'list:user:notice:goodbye.txt') + with open(full_path, 'w', encoding='utf-8') as fp: + print('$user_email just left the $list_name mailing list!', + file=fp) # Write a list-specific welcome message. path = os.path.join(self.var_dir, 'templates', 'lists', 't...@example.com', 'xx') @@ -235,6 +241,23 @@ have any other questions, you may contact message.get_payload(decode=True).decode('utf-8'), 'Wé need your confirmation\n') + def test_goodbye_message(self): + member = subscribe(self._mlist, 'Anne', email='a...@example.com') + # Now there's one message in the virgin queue; get it and clear it. + items = get_queue_messages('virgin', expected_count=1) + # Send anne an unsubscribe message. + language = getUtility(ILanguageManager).get('en') + send_goodbye_message(self._mlist, member.address.email, language) + # There's a new message in the virgin queue. + items = get_queue_messages('virgin', expected_count=1) + message = items[0].msg + self.assertEqual(str(message['subject']), + 'You have been unsubscribed from the Test List ' + 'mailing list') + self.assertMultiLineEqual( + message.get_payload(), + 'a...@example.com just left the Test List mailing list!') + def test_no_welcome_message_to_owners(self): # Welcome messages go only to mailing list members, not to owners. subscribe(self._mlist, 'Anne', MemberRole.owner, 'a...@example.com') ===================================== src/mailman/docs/NEWS.rst ===================================== @@ -24,6 +24,8 @@ Bugs fixed are other requests for it. (Closes #955) * ARC signing now signs after the message has been personalized and decorated. (Closes #896) +* The prior fix for expanding replacements in the ``list:user:notice:goodbye`` + template was incomplete. This is fixed. (Closes #922) .. _news-3.3.5: View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/d73d165d43c09c71e405696b5266e1db1e28de32...b5c15e4d493f3768738ac4449754a064293e21db -- View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/d73d165d43c09c71e405696b5266e1db1e28de32...b5c15e4d493f3768738ac4449754a064293e21db 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