fix(chat): treat a newest known message id of 0 as unknown - #6513
Merged
Conversation
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>
Contributor
|
APK file: https://github.com/nextcloud/talk-android/actions/runs/32261716840/artifacts/9369095310 |
rapterjet2004
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
/backport to stable-xx.x馃 AI (if applicable)