chore: refactor messageSender.send to take an object

pull/2963/head
Audric Ackermann 1 year ago
parent 77a62e82e7
commit 456df58205

@ -535,13 +535,19 @@ async function encryptMessagesAndWrap(
* @param destination the pubkey we should deposit those message to
* @returns the hashes of successful deposit
*/
async function sendEncryptedDataToSnode(
encryptedData: Array<StoreOnNodeData>,
destination: GroupPubkeyType | PubkeyType,
messagesHashesToDelete: Set<string> | null,
revokeParams: RevokeSubaccountParams | null,
unrevokeParams: UnrevokeSubaccountParams | null
): Promise<NotEmptyArrayOfBatchResults | null> {
async function sendEncryptedDataToSnode({
destination,
encryptedData,
messagesHashesToDelete,
revokeParams,
unrevokeParams,
}: {
encryptedData: Array<StoreOnNodeData>;
destination: GroupPubkeyType | PubkeyType;
messagesHashesToDelete: Set<string> | null;
revokeParams: RevokeSubaccountParams | null;
unrevokeParams: UnrevokeSubaccountParams | null;
}): Promise<NotEmptyArrayOfBatchResults | null> {
try {
const batchResults = await pRetry(
async () => {

@ -143,15 +143,13 @@ async function pushChangesToGroupSwarmIfNeeded({
data: encryptedData[index],
}));
// const
const result = await MessageSender.sendEncryptedDataToSnode(
[...encryptedMessage, ...extraMessagesEncrypted],
groupPk,
allOldHashes,
const result = await MessageSender.sendEncryptedDataToSnode({
encryptedData: [...encryptedMessage, ...extraMessagesEncrypted],
destination: groupPk,
messagesHashesToDelete: allOldHashes,
revokeParams,
unrevokeParams
);
unrevokeParams,
});
const expectedReplyLength =
messages.length + // each of those messages are sent as a subrequest

@ -96,13 +96,13 @@ async function pushChangesToUserSwarmIfNeeded() {
};
});
const result = await MessageSender.sendEncryptedDataToSnode(
msgs,
us,
changesToPush.allOldHashes,
null,
null
);
const result = await MessageSender.sendEncryptedDataToSnode({
encryptedData: msgs,
destination: us,
messagesHashesToDelete: changesToPush.allOldHashes,
revokeParams: null,
unrevokeParams: null,
});
const expectedReplyLength =
changesToPush.messages.length + (changesToPush.allOldHashes.size ? 1 : 0);

Loading…
Cancel
Save