Skip to content

Bound a conversation's read point against the present #230

In review

Description

@mpretty-cyro

A conversation's read point (last_read) is a sender's timestamp, and nothing bounds it against the present. One incoming message from a clock far ahead, once read, parks last_read there:

  • _mark_read takes an explicit up_to as given (src/client/client.cpp, Client::_mark_read), and an app marks read up to the newest incoming message it has shown, by that message's timestamp.
  • The timestamp is the sender's signed one, with no check against now (client.cpp, where a received message's timestamp is set).
  • An arrival counts as unread only if it is newer than last_read, so every later message in that conversation arrives already read until the clock catches up.
  • last_read only moves forwards, on a merge from another device and when pushed, so the account's other devices take it too and none can move it back.

In a one-to-one conversation this silences only the sender with the skewed clock. In a conversation with several members, one member's message would silence everyone's.

_mark_read already guards the other way: with no up_to, it marks up to the newest message that exists rather than "everything", because "parking the watermark at infinity would silently mark all future arrivals read". The same can happen through an explicit up_to.

The bound belongs here, where the timestamp arrives, rather than in each app: an app that capped its up_to would leave the future-dated message itself unread until the clock caught up. Two places it could go:

  1. Clamp the timestamp a received message counts by for read state (or the stored timestamp) to now plus a tolerance.
  2. Clamp up_to in _mark_read, and the value taken from a merge, to now plus a tolerance.

Legacy desktop syncs the same thing, the newest read message's sent timestamp, through convo_info_volatile with a max, so the exposure is not new. It is just easier to hit now that read state is decided in one place.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions