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

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

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

Loading…
Cancel
Save