Skip to content

Commit 138f4fb

Browse files
authored
πŸ›(autoreply) do not mark thread as read when sending autoreply (#594)
The autoreply sender is away β€” marking the thread as read prevents them from seeing new messages when they return.
1 parent 0bdeb06 commit 138f4fb

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

β€Žsrc/backend/core/mda/autoreply.pyβ€Ž

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,9 @@ def send_autoreply_for_message(
267267
# 7. Trigger async send (outside transaction to avoid sending before commit)
268268
send_message_task.delay(str(message.id))
269269

270-
# 8. Update thread stats
271-
models.ThreadAccess.objects.filter(
272-
thread=thread,
273-
mailbox=mailbox,
274-
).update(read_at=message.created_at)
275-
270+
# 8. Update thread stats β€” do NOT update read_at here: the autoreply
271+
# sender is away, so the thread must stay unread for them to notice
272+
# new messages when they return.
276273
thread.update_stats()
277274

278275
logger.info(

β€Žsrc/backend/core/tests/mda/test_autoreply.pyβ€Ž

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -919,10 +919,14 @@ def test_has_attachments_persisted_with_inline_signature_images(
919919
assert autoreply_msg.has_attachments is True
920920

921921

922-
def test_updates_sender_read_at(
922+
def test_does_not_update_sender_read_at(
923923
self, mailbox, autoreply_template, inbound_message
924924
):
925-
"""Autoreply should update read_at so the thread does not appear unread."""
925+
"""Autoreply must NOT mark the thread as read for the sender.
926+
927+
The sender has autoreply enabled because they are away. The thread
928+
should remain unread so they can see new messages when they return.
929+
"""
926930
access = models.ThreadAccess.objects.get(
927931
mailbox=mailbox, thread=inbound_message.thread
928932
)
@@ -931,8 +935,4 @@ def test_updates_sender_read_at(
931935
send_autoreply_for_message(autoreply_template, mailbox, inbound_message)
932936

933937
access.refresh_from_db()
934-
autoreply_msg = models.Message.objects.filter(
935-
parent=inbound_message, is_sender=True
936-
).last()
937-
assert access.read_at is not None
938-
assert access.read_at >= autoreply_msg.created_at
938+
assert access.read_at is None

0 commit comments

Comments
Β (0)