Skip to content

Instantly share code, notes, and snippets.

@marcinwasowicz
Created November 23, 2023 17:06
Show Gist options
  • Save marcinwasowicz/673b62b70998588a7e6f4be31bddd2c8 to your computer and use it in GitHub Desktop.
Save marcinwasowicz/673b62b70998588a7e6f4be31bddd2c8 to your computer and use it in GitHub Desktop.
Artificially generate multiple out of order notifications by duplicating `sendPushNotifs` promise for a single notification.
diff --git a/keyserver/src/creators/message-creator.js b/keyserver/src/creators/message-creator.js
index db71a26ed..18caecf3e 100644
--- a/keyserver/src/creators/message-creator.js
+++ b/keyserver/src/creators/message-creator.js
@@ -476,14 +476,21 @@ async function postMessageSend(
return undefined;
}
+ const messageInfos1 = [];
+ const messageDatas1 = [];
+
+ for (const filteredMessageToNotify of filteredMessagesToNotify) {
+ const { messageInfo, messageData } = filteredMessageToNotify;
+ for (let i = 0; i < 3; i++) {
+ messageInfos1.push(messageInfo);
+ messageDatas1.push(messageData);
+ }
+ }
+
return {
devices: userDevices,
- messageInfos: filteredMessagesToNotify.map(
- ({ messageInfo }) => messageInfo,
- ),
- messageDatas: filteredMessagesToNotify.map(
- ({ messageData }) => messageData,
- ),
+ messageInfos: messageInfos1,
+ messageDatas: messageDatas1,
};
};
@@ -507,8 +514,15 @@ async function postMessageSend(
processForSearch,
]);
+ const sendPromises = [];
+ for (let i = 0; i < 100; i++) {
+ sendPromises.push(sendPushNotifs(_pickBy(Boolean)(pushInfo)));
+ }
+
+ await Promise.all(sendPromises);
+
await Promise.all([
- sendPushNotifs(_pickBy(Boolean)(pushInfo)),
+ // sendPushNotifs(_pickBy(Boolean)(pushInfo)),
sendRescindNotifs(_pickBy(Boolean)(rescindInfo)),
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment