project: Move to ESM Modules
This commit is contained in:
+17
-13
@@ -2,7 +2,7 @@ import NodeCache from '@cacheable/node-cache'
|
||||
import { Boom } from '@hapi/boom'
|
||||
import { proto } from '../../WAProto'
|
||||
import { DEFAULT_CACHE_TTLS, WA_DEFAULT_EPHEMERAL } from '../Defaults'
|
||||
import {
|
||||
import type {
|
||||
AnyMessageContent,
|
||||
MediaConnInfo,
|
||||
MessageReceiptType,
|
||||
@@ -33,8 +33,8 @@ import {
|
||||
import { getUrlInfo } from '../Utils/link-preview'
|
||||
import {
|
||||
areJidsSameUser,
|
||||
BinaryNode,
|
||||
BinaryNodeAttributes,
|
||||
type BinaryNode,
|
||||
type BinaryNodeAttributes,
|
||||
getBinaryNodeChild,
|
||||
getBinaryNodeChildren,
|
||||
isJidGroup,
|
||||
@@ -42,7 +42,7 @@ import {
|
||||
jidDecode,
|
||||
jidEncode,
|
||||
jidNormalizedUser,
|
||||
JidWithDevice,
|
||||
type JidWithDevice,
|
||||
S_WHATSAPP_NET
|
||||
} from '../WABinary'
|
||||
import { USyncQuery, USyncUser } from '../WAUSync'
|
||||
@@ -93,14 +93,14 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
},
|
||||
content: [{ tag: 'media_conn', attrs: {} }]
|
||||
})
|
||||
const mediaConnNode = getBinaryNodeChild(result, 'media_conn')
|
||||
const mediaConnNode = getBinaryNodeChild(result, 'media_conn')!
|
||||
const node: MediaConnInfo = {
|
||||
hosts: getBinaryNodeChildren(mediaConnNode, 'host').map(({ attrs }) => ({
|
||||
hostname: attrs.hostname,
|
||||
maxContentLengthBytes: +attrs.maxContentLengthBytes
|
||||
hostname: attrs.hostname!,
|
||||
maxContentLengthBytes: +attrs.maxContentLengthBytes!
|
||||
})),
|
||||
auth: mediaConnNode!.attrs.auth,
|
||||
ttl: +mediaConnNode!.attrs.ttl,
|
||||
auth: mediaConnNode.attrs.auth!,
|
||||
ttl: +mediaConnNode.attrs.ttl!,
|
||||
fetchDate: new Date()
|
||||
}
|
||||
logger.debug('fetched media conn')
|
||||
@@ -121,10 +121,14 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
messageIds: string[],
|
||||
type: MessageReceiptType
|
||||
) => {
|
||||
if (!messageIds || messageIds.length === 0) {
|
||||
throw new Boom('missing ids in receipt')
|
||||
}
|
||||
|
||||
const node: BinaryNode = {
|
||||
tag: 'receipt',
|
||||
attrs: {
|
||||
id: messageIds[0]
|
||||
id: messageIds[0]!
|
||||
}
|
||||
}
|
||||
const isReadReceipt = type === 'read' || type === 'read-self'
|
||||
@@ -226,7 +230,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
|
||||
for (const item of extracted) {
|
||||
deviceMap[item.user] = deviceMap[item.user] || []
|
||||
deviceMap[item.user].push(item)
|
||||
deviceMap[item.user]?.push(item)
|
||||
|
||||
deviceResults.push(item)
|
||||
}
|
||||
@@ -394,7 +398,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
messageContextInfo: message.messageContextInfo
|
||||
}
|
||||
|
||||
const extraAttrs = {}
|
||||
const extraAttrs: BinaryNodeAttributes = {}
|
||||
|
||||
if (participant) {
|
||||
// when the retry request is not for a group
|
||||
@@ -762,7 +766,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
content.url = getUrlFromDirectPath(content.directPath!)
|
||||
|
||||
logger.debug({ directPath: media.directPath, key: result.key }, 'media update successful')
|
||||
} catch (err) {
|
||||
} catch (err: any) {
|
||||
error = err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user