chore: lint
This commit is contained in:
@@ -16,7 +16,7 @@ export abstract class AbstractSocketClient extends EventEmitter {
|
||||
this.setMaxListeners(0)
|
||||
}
|
||||
|
||||
abstract connect(): Promise<void>
|
||||
abstract close(): Promise<void>
|
||||
abstract connect(): void
|
||||
abstract close(): void
|
||||
abstract send(str: Uint8Array | string, cb?: (err?: Error) => void): boolean
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export class WebSocketClient extends AbstractSocketClient {
|
||||
return this.socket?.readyState === WebSocket.CONNECTING
|
||||
}
|
||||
|
||||
async connect(): Promise<void> {
|
||||
connect() {
|
||||
if (this.socket) {
|
||||
return
|
||||
}
|
||||
@@ -40,7 +40,7 @@ export class WebSocketClient extends AbstractSocketClient {
|
||||
}
|
||||
}
|
||||
|
||||
async close(): Promise<void> {
|
||||
close() {
|
||||
if (!this.socket) {
|
||||
return
|
||||
}
|
||||
|
||||
+18
-18
@@ -145,7 +145,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
logger.debug({ messageKey }, 'already requested resend')
|
||||
return
|
||||
} else {
|
||||
placeholderResendCache.set(messageKey?.id!, true)
|
||||
await placeholderResendCache.set(messageKey?.id!, true)
|
||||
}
|
||||
|
||||
await delay(5000)
|
||||
@@ -164,10 +164,10 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
peerDataOperationRequestType: proto.Message.PeerDataOperationRequestType.PLACEHOLDER_MESSAGE_RESEND
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
setTimeout(async () => {
|
||||
if (placeholderResendCache.get(messageKey?.id!)) {
|
||||
logger.debug({ messageKey }, 'PDO message without response after 15 seconds. Phone possibly offline')
|
||||
placeholderResendCache.del(messageKey?.id!)
|
||||
await placeholderResendCache.del(messageKey?.id!)
|
||||
}
|
||||
}, 15_000)
|
||||
|
||||
@@ -403,14 +403,14 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
|
||||
// Use the new retry count for the rest of the logic
|
||||
const key = `${msgId}:${msgKey?.participant}`
|
||||
msgRetryCache.set(key, retryCount)
|
||||
await msgRetryCache.set(key, retryCount)
|
||||
} else {
|
||||
// Fallback to old system
|
||||
const key = `${msgId}:${msgKey?.participant}`
|
||||
let retryCount = (await msgRetryCache.get<number>(key)) || 0
|
||||
if (retryCount >= maxMsgRetryCount) {
|
||||
logger.debug({ retryCount, msgId }, 'reached retry limit, clearing')
|
||||
msgRetryCache.del(key)
|
||||
await msgRetryCache.del(key)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1031,7 +1031,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
if (!ids[i]) continue
|
||||
|
||||
if (msg && (await willSendMessageAgain(ids[i], participant))) {
|
||||
updateSendMessageAgainCount(ids[i], participant)
|
||||
await updateSendMessageAgainCount(ids[i], participant)
|
||||
const msgRelayOpts: MessageRelayOptions = { messageId: ids[i] }
|
||||
|
||||
if (sendToAll) {
|
||||
@@ -1122,7 +1122,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
if (ids[0] && key.participant && (await willSendMessageAgain(ids[0], key.participant))) {
|
||||
if (key.fromMe) {
|
||||
try {
|
||||
updateSendMessageAgainCount(ids[0], key.participant)
|
||||
await updateSendMessageAgainCount(ids[0], key.participant)
|
||||
logger.debug({ attrs, key }, 'recv retry request')
|
||||
await sendMessagesAgain(key, ids, retryNode!)
|
||||
} catch (error: unknown) {
|
||||
@@ -1257,7 +1257,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
logger.debug(`[handleMessage] Attempting retry request for failed decryption`)
|
||||
|
||||
// Handle both pre-key and normal retries in single mutex
|
||||
retryMutex.mutex(async () => {
|
||||
await retryMutex.mutex(async () => {
|
||||
try {
|
||||
if (!ws.isOpen) {
|
||||
logger.debug({ node }, 'Connection closed, skipping retry')
|
||||
@@ -1499,7 +1499,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
|
||||
const offlineNodeProcessor = makeOfflineNodeProcessor()
|
||||
|
||||
const processNode = (
|
||||
const processNode = async (
|
||||
type: MessageType,
|
||||
node: BinaryNode,
|
||||
identifier: string,
|
||||
@@ -1510,31 +1510,31 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
if (isOffline) {
|
||||
offlineNodeProcessor.enqueue(type, node)
|
||||
} else {
|
||||
processNodeWithBuffer(node, identifier, exec)
|
||||
await processNodeWithBuffer(node, identifier, exec)
|
||||
}
|
||||
}
|
||||
|
||||
// recv a message
|
||||
ws.on('CB:message', (node: BinaryNode) => {
|
||||
processNode('message', node, 'processing message', handleMessage)
|
||||
ws.on('CB:message', async (node: BinaryNode) => {
|
||||
await processNode('message', node, 'processing message', handleMessage)
|
||||
})
|
||||
|
||||
ws.on('CB:call', async (node: BinaryNode) => {
|
||||
processNode('call', node, 'handling call', handleCall)
|
||||
await processNode('call', node, 'handling call', handleCall)
|
||||
})
|
||||
|
||||
ws.on('CB:receipt', node => {
|
||||
processNode('receipt', node, 'handling receipt', handleReceipt)
|
||||
ws.on('CB:receipt', async node => {
|
||||
await processNode('receipt', node, 'handling receipt', handleReceipt)
|
||||
})
|
||||
|
||||
ws.on('CB:notification', async (node: BinaryNode) => {
|
||||
processNode('notification', node, 'handling notification', handleNotification)
|
||||
await processNode('notification', node, 'handling notification', handleNotification)
|
||||
})
|
||||
ws.on('CB:ack,class:message', (node: BinaryNode) => {
|
||||
handleBadAck(node).catch(error => onUnexpectedError(error, 'handling bad ack'))
|
||||
})
|
||||
|
||||
ev.on('call', ([call]) => {
|
||||
ev.on('call', async ([call]) => {
|
||||
if (!call) {
|
||||
return
|
||||
}
|
||||
@@ -1562,7 +1562,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
}
|
||||
|
||||
const protoMsg = proto.WebMessageInfo.fromObject(msg) as WAMessage
|
||||
upsertMessage(protoMsg, call.offline ? 'append' : 'notify')
|
||||
await upsertMessage(protoMsg, call.offline ? 'append' : 'notify')
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -946,7 +946,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
const tcTokenBuffer = contactTcTokenData[destinationJid]?.token
|
||||
|
||||
if (tcTokenBuffer) {
|
||||
(stanza.content as BinaryNode[]).push({
|
||||
;(stanza.content as BinaryNode[]).push({
|
||||
tag: 'tctoken',
|
||||
attrs: {},
|
||||
content: tcTokenBuffer
|
||||
@@ -1198,8 +1198,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
additionalNodes
|
||||
})
|
||||
if (config.emitOwnEvents) {
|
||||
process.nextTick(() => {
|
||||
processingMutex.mutex(() => upsertMessage(fullMsg, 'append'))
|
||||
process.nextTick(async () => {
|
||||
await processingMutex.mutex(() => upsertMessage(fullMsg, 'append'))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
}
|
||||
}).finish()
|
||||
)
|
||||
noise.finishInit()
|
||||
await noise.finishInit()
|
||||
startKeepAliveRequest()
|
||||
}
|
||||
|
||||
@@ -566,8 +566,8 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
}
|
||||
}
|
||||
|
||||
const onMessageReceived = (data: Buffer) => {
|
||||
noise.decodeFrame(data, frame => {
|
||||
const onMessageReceived = async (data: Buffer) => {
|
||||
await noise.decodeFrame(data, frame => {
|
||||
// reset ping timeout
|
||||
lastDateRecv = new Date()
|
||||
|
||||
@@ -968,9 +968,9 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
end(new Boom('Multi-device beta not joined', { statusCode: DisconnectReason.multideviceMismatch }))
|
||||
})
|
||||
|
||||
ws.on('CB:ib,,offline_preview', (node: BinaryNode) => {
|
||||
ws.on('CB:ib,,offline_preview', async (node: BinaryNode) => {
|
||||
logger.info('offline preview received', JSON.stringify(node))
|
||||
sendNode({
|
||||
await sendNode({
|
||||
tag: 'ib',
|
||||
attrs: {},
|
||||
content: [{ tag: 'offline_batch', attrs: { count: '100' } }]
|
||||
|
||||
Reference in New Issue
Block a user