Filter response from Mailman3 held messages queue.
I'm working on an update to a portion of my team's application. It retrieves the held messages from Mailman and returns them to the client so that our admins can approve/reject them. At the moment it works as intended, but displays far too much information because Mailman is returning the entire email, with headers (see below).
I've found some libraries which can parse the message property and extract the relevant bits, but I'd rather pass some sort of flag or filter to the initial Mailman 3 API call and get back less information. I've looked through the documentation but I'm not finding anything of the sort. Would this be useful?
{
"request_id": "1",
"original_size": 855,
"sender": "dev@email.org",
"subject": "Testing one two three",
"hold_date": new Date(),
"msg": "Received: from [127.0.0.1] (localhost [127.0.0.1])\n\t(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)\n\t key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)\n\t(No client certificate requested)\n\t(Authenticated sender: dev@email.org)\n\tby mailman.default.svc.cluster.local (Postfix) with ESMTPSA id A48A33E9849\n\tfor <abc-announce@email.org>; Thu, 23 Jan 2025 21:24:11 +0000 (UTC)\nMessage-ID: <3ecbaccf-f65a-4ce5-bdfa-e08b5659dc32@email.org>\nDate: Thu, 23 Jan 2025 15:24:11 -0600\nMIME-Version: 1.0\nUser-Agent: Mozilla Thunderbird\nContent-Language: en-US\nTo: abc-announce@email.org\nFrom: Dev Tester <dev@email.org>\nSubject: Testing one two three\nContent-Type: text/plain; charset=UTF-8; format=flowed\nContent-Transfer-Encoding: 7bit\nX-MailFrom: dev@email.org\nX-Mailman-Rule-Hits: nonmember-moderation\nX-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation\nMessage-ID-Hash: XM4OS47LU7DRYIO74WB5K4W345NPZ37O\nX-Message-ID-Hash: XM4OS47LU7DRYIO74WB5K4W345NPZ37O\n\nThis is a single line message body.\n\n"
}
Andy Matthews writes:
I've found some libraries which can parse the message property and extract the relevant bits, but I'd rather pass some sort of flag or filter to the initial Mailman 3 API call and get back less information.
Before I express my opinion, note that I am not authoritative on this, but I have a decent record on channeling the consensus. So YMMV FWIW
I'd be against putting such a thing into the core without a lot of beta testing, I think. I imagine there would be various opinions on how much less and which data should come back.
There is a plugin architecture which specifically can be used to implement REST routes: https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/plugins/doc... While doing it this way undoubtedly makes it more complicated for the initial implementer, I think it would be a lot simpler (more self-contained) for people who want to implement different filters, etc.
I've looked through the documentation but I'm not finding anything of the sort.
I don't think there is for this, although there's a certain amount of code for filtering the messages that are being processed (stripping attachments of specified MIME types, converting text/html to text/plain, etc). I'm not sure if that's done in advance of holding for moderation. So maybe it would be OK to repurpose that code to your end (though I'd want it to be a proper refactoring, not cargo culting the post distribution filter into the moderation code), and somebody would need to do the same for Postorius. Not necessarily you (I infer you're talking about a separate application that talks to Mailman core for moderation), but availability to Postorius users with common administrative UI would make it a lot more attractive to us.
Hrm. Interesting thoughts, thank you Stephen. At a previous job we used the concept of expansions to dictate what was returned to the caller; this I think would be the opposite.
I've got another possibility which is to parse the message body after retrieval from the API, but before returning it to my Angular client. I'll report back if I have success, and perhaps I can share that code.
participants (2)
-
Andy Matthews
-
Stephen J. Turnbull