Skip to content

fix(chat): treat a newest known message id of 0 as unknown - #6513

Merged
mahibi merged 1 commit into
masterfrom
bugfix/noid/fixPlausibleLastReadMessageGuard
Aug 19, 2026
Merged

fix(chat): treat a newest known message id of 0 as unknown#6513
mahibi merged 1 commit into
masterfrom
bugfix/noid/fixPlausibleLastReadMessageGuard

Conversation

@mahibi

@mahibi mahibi commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

isPlausibleLastReadMessageId rejects a read position more than 10,000 above the conversation's cached newest known message id, guarding against a hash-derived placeholder id being mistaken for a real read position. A federated conversation's cached lastMessage can carry an id of 0 when it was never populated - a real server-assigned message id is never 0 or negative, so that can only mean the newest known id isn't actually known, not that message ids near 0 are the real ceiling.

Without this, every real read position in such a room gets rejected as implausible forever: localLastReadMessage never advances past 0, updateRemoteLastReadMessageIfNeeded never finds a reason to send a marker, and the conversation never gets marked as read after leaving the chat.

Treat a newest known id of 0 (or negative) the same as null, and name the resulting reference point explicitly so the guard's intent - is there a trustworthy ceiling to judge the candidate against at all - is readable from the code rather than from the comparison operator.

Assisted-by: Claude Sonnet 5 noreply@anthropic.com

馃弫 Checklist

  • 鉀戯笍 Tests (unit and/or integration) are included or not needed
  • 馃敄 Capability is checked or not needed
  • 馃敊 Backport requests are created or not needed: /backport to stable-xx.x
  • 馃搮 Milestone is set
  • 馃尭 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

馃 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

isPlausibleLastReadMessageId rejects a read position more than 10,000
above the conversation's cached newest known message id, guarding
against a hash-derived placeholder id being mistaken for a real read
position. A federated conversation's cached lastMessage can carry an id
of 0 when it was never populated - a real server-assigned message id is
never 0 or negative, so that can only mean the newest known id isn't
actually known, not that message ids near 0 are the real ceiling.

Without this, every real read position in such a room gets rejected as
implausible forever: localLastReadMessage never advances past 0,
updateRemoteLastReadMessageIfNeeded never finds a reason to send a
marker, and the conversation never gets marked as read after leaving
the chat.

Treat a newest known id of 0 (or negative) the same as null, and name
the resulting reference point explicitly so the guard's intent - is
there a trustworthy ceiling to judge the candidate against at all - is
readable from the code rather than from the comparison operator.

Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@mahibi
mahibi requested a review from rapterjet2004 August 19, 2026 14:03
@mahibi mahibi self-assigned this Aug 19, 2026
@mahibi mahibi added the 3. to review Waiting for reviews label Aug 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/32261716840/artifacts/9369095310
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@mahibi
mahibi merged commit 3fcb1fb into master Aug 19, 2026
17 of 20 checks passed
@mahibi
mahibi deleted the bugfix/noid/fixPlausibleLastReadMessageGuard branch August 19, 2026 16:35
@mahibi mahibi added this to the 25.0.0 milestone Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants