Make mark-all-read atomic

This commit is contained in:
Jack Kingsman
2026-02-12 00:19:37 -08:00
parent b83edfda74
commit b80093ba94
2 changed files with 2 additions and 2 deletions

View File

@@ -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:

View File

@@ -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}