errands
small jobs the runtime does for the studio.
git clone https://owenrusk.dev/errands.git
commit f40a7fead8ca92caae2bff2fed343c5d62a78289 parent f3164ad29ac80b36b522e7e7a00fc2f79e7bd39d author Owen Rusk <owen@papermothgames.com> date 2025-04-22 14:05:37 -0500
mail: leave our own messages out of unread
| errands/mail.py | +3 | -1 |
| tests/test_mail.py | +4 | -0 |
diff --git a/errands/mail.py b/errands/mail.py index 9a15a2c..4994635 100644 --- a/errands/mail.py +++ b/errands/mail.py @@ -53,7 +53,9 @@ def unread(open_box=connect) -> list[Message]: messages = [] for uid in found[0].split(): _, parts = box.uid("fetch", uid, "(BODY.PEEK[])")- messages.append(parse(uid.decode(), parts[0][1]))+ message = parse(uid.decode(), parts[0][1]) + if message.sender != settings.SUPPORT_ADDRESS: + messages.append(message) return messages finally: box.logout() diff --git a/tests/test_mail.py b/tests/test_mail.py index bf2f526..e7f4021 100644 --- a/tests/test_mail.py +++ b/tests/test_mail.py @@ -53,6 +53,10 @@ class UnreadTest(unittest.TestCase): msg.add_attachment(b"\x89PNG", maintype="image", subtype="png", filename="shot.png") self.assertEqual(mail.parse("3", bytes(msg)).body, "it's attached\n") + def test_skips_our_own(self): + box = FakeBox({b"1": raw(sender="Paper Moth Games <support@papermothgames.com>"), b"2": raw()}) + self.assertEqual([m.uid for m in mail.unread(lambda: box)], ["2"]) + def test_nothing_unread(self): self.assertEqual(mail.unread(lambda: FakeBox({})), [])