From b80093ba94cdfa62d13cd6819dc284fc22c42ac0 Mon Sep 17 00:00:00 2001 From: Jack Kingsman Date: Thu, 12 Feb 2026 00:19:37 -0800 Subject: [PATCH] Make mark-all-read atomic --- app/repository.py | 2 ++ app/routers/read_state.py | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/repository.py b/app/repository.py index 9f0ce6f..00a9b73 100644 --- a/app/repository.py +++ b/app/repository.py @@ -223,6 +223,7 @@ class ContactRepository: async def mark_all_read(timestamp: int) -> None: """Mark all contacts as read at the given timestamp.""" await db.conn.execute("UPDATE contacts SET last_read_at = ?", (timestamp,)) + await db.conn.commit() @staticmethod async def get_by_pubkey_first_byte(hex_byte: str) -> list[Contact]: @@ -314,6 +315,7 @@ class ChannelRepository: async def mark_all_read(timestamp: int) -> None: """Mark all channels as read at the given timestamp.""" await db.conn.execute("UPDATE channels SET last_read_at = ?", (timestamp,)) + await db.conn.commit() class MessageRepository: diff --git a/app/routers/read_state.py b/app/routers/read_state.py index 5135d19..365b695 100644 --- a/app/routers/read_state.py +++ b/app/routers/read_state.py @@ -5,7 +5,6 @@ import time from fastapi import APIRouter, Query -from app.database import db from app.models import UnreadCounts from app.repository import ChannelRepository, ContactRepository, MessageRepository @@ -37,7 +36,6 @@ async def mark_all_read() -> dict: await ContactRepository.mark_all_read(now) await ChannelRepository.mark_all_read(now) - await db.conn.commit() logger.info("Marked all contacts and channels as read at %d", now) return {"status": "ok", "timestamp": now}