errands
small jobs the runtime does for the studio.
git clone https://owenrusk.dev/errands.git
commit 061212799d09811db597cde12d9dbb84327bad87 parent 83f1aa0584af4df7e50080123def3131ee533a78 author Owen Rusk <owen@papermothgames.com> date 2024-11-05 13:20:44 -0600
mail: keep the thread together on replies
| errands/mail.py | +3 | -0 |
| tests/test_mail.py | +1 | -0 |
diff --git a/errands/mail.py b/errands/mail.py index 5050c01..9a15a2c 100644 --- a/errands/mail.py +++ b/errands/mail.py @@ -15,6 +15,7 @@ class Message: sender: str subject: str message_id: str + references: str body: str @@ -40,6 +41,7 @@ def parse(uid: str, raw: bytes) -> Message: sender=parseaddr(msg.get("From", ""))[1].lower(), subject=msg.get("Subject", ""), message_id=msg.get("Message-ID", ""), + references=msg.get("References", ""), body=text(msg), ) @@ -74,6 +76,7 @@ def compose(to: str, subject: str, body: str, reply_to: Message | None = None) - msg["Message-ID"] = make_msgid(domain="papermothgames.com") if reply_to is not None: msg["In-Reply-To"] = reply_to.message_id + msg["References"] = f"{reply_to.references} {reply_to.message_id}".strip() msg.set_content(body) return msg diff --git a/tests/test_mail.py b/tests/test_mail.py index bde07b7..bf2f526 100644 --- a/tests/test_mail.py +++ b/tests/test_mail.py @@ -83,6 +83,7 @@ class SendTest(unittest.TestCase): self.assertEqual(sent["To"], "someone@example.com") self.assertEqual(sent["Subject"], "Re: a question") self.assertEqual(sent["In-Reply-To"], "<q@example.com>") + self.assertEqual(sent["References"], "<q@example.com>") self.assertEqual(sent["From"], "Paper Moth Games <support@papermothgames.com>") self.assertTrue(server.quit_called)