chore: make APIs similar for legacy + MD

This commit is contained in:
Adhiraj Singh
2021-12-18 16:44:31 +05:30
parent c803e22e8a
commit e393f0f9a8
7 changed files with 33 additions and 30 deletions

View File

@@ -62,7 +62,7 @@ export const makeSocket = ({
* Send a message to the WA servers
* @returns the tag attached in the message
* */
const sendMessage = async(
const sendNode = async(
{ json, binaryTag, tag, longTag }: SocketSendMessageOptions
) => {
tag = tag || generateMessageTag(longTag)
@@ -204,7 +204,7 @@ export const makeSocket = ({
}
}
/** checks for phone connection */
const sendAdminTest = () => sendMessage({ json: ['admin', 'test'] })
const sendAdminTest = () => sendNode({ json: ['admin', 'test'] })
/**
* Wait for a message with a certain tag to be received
* @param tag the message tag to await
@@ -266,7 +266,7 @@ export const makeSocket = ({
tag = tag || generateMessageTag(longTag)
const { promise, cancelToken } = waitForMessage(tag, requiresPhoneConnection, timeoutMs)
try {
await sendMessage({ json, tag, binaryTag })
await sendNode({ json, tag, binaryTag })
} catch(error) {
cancelToken()
// swallow error
@@ -366,8 +366,7 @@ export const makeSocket = ({
ws,
updateKeys: (info: { encKey: Buffer, macKey: Buffer }) => authInfo = info,
waitForSocketOpen,
sendRawMessage,
sendMessage,
sendNode,
generateMessageTag,
waitForMessage,
query,