Skip to content

Commit

Permalink
[keyserver] await INSERT INTO messages before calling postMessageSend
Browse files Browse the repository at this point in the history
Summary:
We want to check if there is a collision on the `INSERT` before calling `postMessageSend` in order to avoid creating duplicate notifs or `UpdateInfo`s.

See [ENG-4563](https://linear.app/comm/issue/ENG-4563/doubled-messagenotification) for more details.

Test Plan: I tested message creation to make sure it still works

Reviewers: kamil, michal, atul, tomek

Reviewed By: atul

Differential Revision: https://phab.comm.dev/D8700
  • Loading branch information
Ashoat committed Aug 2, 2023
1 parent d435341 commit f58ed7a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions keyserver/src/creators/message-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async function createMessages(
creation, target_message)
VALUES ${messageInsertRows}
`;
const messageInsertPromise = dbQuery(messageInsertQuery);
await dbQuery(messageInsertQuery);

const postMessageSendPromise = postMessageSend(
viewer,
Expand All @@ -204,7 +204,6 @@ async function createMessages(
}

await Promise.all([
messageInsertPromise,
updateRepliesCount(threadsToMessageIndices, newMessageDatas),
viewer.isScriptViewer ? postMessageSendPromise : undefined,
]);
Expand Down

0 comments on commit f58ed7a

Please sign in to comment.