Page MenuHomePhabricator

Mailman3 is not importing list footers ("templates") as expected
Closed, ResolvedPublic

Description

Reported by @Urbanecm in WikimediaCZ-l.

The variable syntax is different in MM3 and doesn't seem to be migrated by the script.

Event Timeline

Legoktm created this task.

From https://gitlab.com/mailman/mailman/-/issues/870#note_553840180

As far as import21 is concerned, the syntax of replacements and the actual replacement names are different between Mailman 2.1 and 3. import21 "fixes" a few of these on import, but ones it doesn't recognize are imported as is.

Of course, the worst part is that these "imported" templates aren't actually visible in postorius because:

Basically, Postorius has it's own notion of templates and when you create a template in Postorius, it replaces the list's URI for that template with a URI to get the template from Postorius. Postorius needs to be updated to show the content for the existing URI when Postorius doesn't have a template.

So listadmins can't see the templates that exist and then can't fix them. We should import the templates off disk and drop them into postorius somehow and then tell listadmins to check/fix templates as needed.

Templates are very not-properly implemented upstream so my plan is hackish:

  • Set global English defaults for templates via Puppet. This will provide a good UX since the default templates are not great and it will make it easy for listadmins to determine what the defaults are since postorius doesn't show them to you!
    • If this works, we should add these templates to TWN and deploy them as a .deb probably.
  • During the import process, put the imported templates into the postorius database (mailman3web.postorius_emailtemplate) and update the mailman database to point to that template (mailman3.template). Then delete the templates off of disk
    • This will require that the import script makes a MySQL insert into the postorius DB since there's no API. We can use the mmclient REST API for the second part
  • Update documentation to instruct list admins to review the templates and edit/update them as needed post-migration
  • Work with upstream to get this fixed properly, maybe ask for some funding if necessary.

Notes:

MariaDB [mailman3]> select * from template where context="test.lists.wikimedia.org";
+----+----------------------------+--------------------------+-------------------------------------------------------------------------------------------------------+----------+----------+
| id | name                       | context                  | uri                                                                                                   | username | password |
+----+----------------------------+--------------------------+-------------------------------------------------------------------------------------------------------+----------+----------+
|  1 | list:member:regular:footer | test.lists.wikimedia.org | mailman:///$listname/$language/list:member:regular:footer.txt                                         | NULL     |          |
|  7 | list:member:digest:footer  | test.lists.wikimedia.org | http://localhost:8000/postorius/api/templates/list/test.lists.wikimedia.org/list:member:digest:footer | NULL     |          |
+----+----------------------------+--------------------------+-------------------------------------------------------------------------------------------------------+----------+----------+
2 rows in set (0.000 sec)

Upstream issues:

Change 683477 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/puppet@production] mailman3: Properly import templates for admins

https://gerrit.wikimedia.org/r/683477

Change 683520 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/puppet@production] mailman3: Fix URL postorius provides to fetch templates

https://gerrit.wikimedia.org/r/683520

Change 683555 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/puppet@production] mailman3: Fork and improve upstream templates

https://gerrit.wikimedia.org/r/683555

Change 683520 merged by Legoktm:

[operations/puppet@production] mailman3: Fix URL postorius provides to fetch templates

https://gerrit.wikimedia.org/r/683520

Change 683477 merged by Legoktm:

[operations/puppet@production] mailman3: Properly import templates for admins

https://gerrit.wikimedia.org/r/683477

Change 683555 merged by Legoktm:

[operations/puppet@production] mailman3: Fork and improve upstream templates

https://gerrit.wikimedia.org/r/683555

Documented at https://meta.wikimedia.org/wiki/Mailing_lists/Mailman3_migration#Review_custom_footer_and_other_templates (thanks to @Quiddity for reviewing)

And then I fixed the already imported lists, only wikimediacz-l seemed to have syntax that didn't get properly migrated so I pinged @Urbanecm and he fixed it.

legoktm@lists1001:~$ sudo python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from migrate_to_mailman3 import fix_templates
>>> fix_templates('lgbt')
Importing list:member:regular:footer.txt
Inserted 1 templates into `postorius_emailtemplate`.
Updated mailman3.template table to point to postorius
Deleted /var/lib/mailman3/templates/lists/lgbt.lists.wikimedia.org/en
Deleted /var/lib/mailman3/templates/lists/lgbt.lists.wikimedia.org
>>> fix_templates('wikifa-admin-l')
Importing list:member:digest:footer.txt
Importing list:member:regular:footer.txt
Inserted 2 templates into `postorius_emailtemplate`.
Updated mailman3.template table to point to postorius
Deleted /var/lib/mailman3/templates/lists/wikifa-admin-l.lists.wikimedia.org/en
Deleted /var/lib/mailman3/templates/lists/wikifa-admin-l.lists.wikimedia.org
>>> fix_templates('wikimediacz-l')
Importing list:member:regular:footer.txt
Inserted 1 templates into `postorius_emailtemplate`.
Updated mailman3.template table to point to postorius
Deleted /var/lib/mailman3/templates/lists/wikimediacz-l.lists.wikimedia.org/en
Deleted /var/lib/mailman3/templates/lists/wikimediacz-l.lists.wikimedia.org
>>> fix_templates('wikimediabr-l')
Importing list:user:notice:goodbye.txt
Inserted 1 templates into `postorius_emailtemplate`.
Updated mailman3.template table to point to postorius
Deleted /var/lib/mailman3/templates/lists/wikimediabr-l.lists.wikimedia.org/pt_BR
Deleted /var/lib/mailman3/templates/lists/wikimediabr-l.lists.wikimedia.org