Page MenuHomePhabricator

[keyserver] Fix message creation when some (but not all) messages already exist
ClosedPublic

Authored by ashoat on Feb 18 2023, 12:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jan 6, 10:05 PM
Unknown Object (File)
Mon, Jan 6, 10:05 PM
Unknown Object (File)
Mon, Jan 6, 10:05 PM
Unknown Object (File)
Mon, Jan 6, 10:04 PM
Unknown Object (File)
Mon, Jan 6, 10:00 PM
Unknown Object (File)
Sun, Jan 5, 4:39 PM
Unknown Object (File)
Dec 2 2024, 6:08 PM
Unknown Object (File)
Dec 2 2024, 6:07 PM
Subscribers
None

Details

Summary

threadsToMessageIndices can have the wrong index if some existingMessages get added to messageInfos before the new messages start being created. The existing code basically assumes messageInfos is empty at the start the message creation loop.

This scenario never occurs for us since an "already existing message" only occurs in the case of a client-composable message, and those messages only ever get passed to createMessages one-at-a-time. But it's still better to have this code fixed up than to have this bug.

Test Plan
  1. I created a message "first" on web that generated a notif on iOS
  2. I checked its localID in the database, and then I applied this patch to my local keyserver
  3. I create a second message "second" and saw that the notif was (incorrectly) referring to "first" before this diff, but fixed to be "second" after this diff

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage