HomePhabricator
Diffusion Comm 92bcac9788c8

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

Description

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

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

Reviewers: tomek, atul

Reviewed By: atul

Differential Revision: https://phab.comm.dev/D6768