feat(subscriptions): mark a single thread as read via REST tmid

GG
1mo ago
+144-43

Summary

Extends POST /v1/subscriptions.read with an optional tmid field so the client can mark a single thread as read over REST instead of via the readThreads DDP method.

When tmid is supplied the server resolves the owning message, validates it belongs to the target room, and marks just that thread as read via readThreadMethod. Without tmid the endpoint behaves exactly as before (marks the whole room).

Changes

AreaChange
POST /v1/subscriptions.readOptional tmid. Validates the thread belongs to the room (error-invalid-thread otherwise) and marks the thread read.
threads/server/functions.tsNew readThreadMethod centralizing the legacy readThreads behavior (threads-enabled check, room/access validation, beforeReadMessages callback, readThread).
readThreads DDP methodRefactored to delegate to readThreadMethod and log a deprecation pointing at /v1/subscriptions.read (kept for external SDK/mobile until 9.0.0).
Client callersThreadChat.tsx and useThreadMessagesQuery.ts migrated from readThreads DDP to the REST endpoint.

Test plan

  • Open a thread → unread counter clears.
  • POST /v1/subscriptions.read with { rid, tmid } marks only that thread read.
  • POST /v1/subscriptions.read with a tmid that does not belong to rid → 400 error-invalid-thread.
  • readThreads DDP still works (logs deprecation).

Summary by CodeRabbit

  • New Features

    • Thread read status can now be updated for a specific thread in the app and via the API.
    • The read-status request now accepts an optional thread ID field for more precise behavior.
  • Bug Fixes

    • Thread read updates now validate that the selected thread belongs to the current room.
    • Thread message loading now keeps read state in sync without blocking message retrieval.
  • Chores

    • Added notes for the API and migration changes.
    • Updated end-to-end coverage for thread read scenarios.