project: Move to ESM Modules
This commit is contained in:
+18
-14
@@ -1,7 +1,7 @@
|
||||
import { Boom } from '@hapi/boom'
|
||||
import { AxiosRequestConfig } from 'axios'
|
||||
import type { AxiosRequestConfig } from 'axios'
|
||||
import { proto } from '../../WAProto'
|
||||
import {
|
||||
import type {
|
||||
BaileysEventEmitter,
|
||||
Chat,
|
||||
ChatModification,
|
||||
@@ -14,9 +14,13 @@ import {
|
||||
WAPatchCreate,
|
||||
WAPatchName
|
||||
} from '../Types'
|
||||
import { ChatLabelAssociation, LabelAssociationType, MessageLabelAssociation } from '../Types/LabelAssociation'
|
||||
import {
|
||||
BinaryNode,
|
||||
type ChatLabelAssociation,
|
||||
LabelAssociationType,
|
||||
type MessageLabelAssociation
|
||||
} from '../Types/LabelAssociation'
|
||||
import {
|
||||
type BinaryNode,
|
||||
getBinaryNodeChild,
|
||||
getBinaryNodeChildren,
|
||||
isJidGroup,
|
||||
@@ -25,7 +29,7 @@ import {
|
||||
} from '../WABinary'
|
||||
import { aesDecrypt, aesEncrypt, hkdf, hmacSign } from './crypto'
|
||||
import { toNumber } from './generics'
|
||||
import { ILogger } from './logger'
|
||||
import type { ILogger } from './logger'
|
||||
import { LT_HASH_ANTI_TAMPERING } from './lt-hash'
|
||||
import { downloadContentFromMessage } from './messages-media'
|
||||
|
||||
@@ -343,7 +347,7 @@ export const extractSyncdPatches = async (result: BinaryNode, options: AxiosRequ
|
||||
|
||||
const syncd = proto.SyncdPatch.decode(content as Uint8Array)
|
||||
if (!syncd.version) {
|
||||
syncd.version = { version: +collectionNode.attrs.version + 1 }
|
||||
syncd.version = { version: +collectionNode.attrs.version! + 1 }
|
||||
}
|
||||
|
||||
syncds.push(syncd)
|
||||
@@ -616,7 +620,7 @@ export const chatModificationToAppPatch = (mod: ChatModification, jid: string) =
|
||||
operation: mod.contact ? OP.SET : OP.REMOVE
|
||||
}
|
||||
} else if ('star' in mod) {
|
||||
const key = mod.star.messages[0]
|
||||
const key = mod.star.messages[0]!
|
||||
patch = {
|
||||
syncAction: {
|
||||
starAction: {
|
||||
@@ -753,7 +757,7 @@ export const processSyncAction = (
|
||||
{
|
||||
id,
|
||||
muteEndTime: action.muteAction?.muted ? toNumber(action.muteAction.muteEndTimestamp) : null,
|
||||
conditional: getChatUpdateConditional(id, undefined)
|
||||
conditional: getChatUpdateConditional(id!, undefined)
|
||||
}
|
||||
])
|
||||
} else if (action?.archiveChatAction || type === 'archive' || type === 'unarchive') {
|
||||
@@ -782,7 +786,7 @@ export const processSyncAction = (
|
||||
{
|
||||
id,
|
||||
archived: isArchived,
|
||||
conditional: getChatUpdateConditional(id, msgRange)
|
||||
conditional: getChatUpdateConditional(id!, msgRange)
|
||||
}
|
||||
])
|
||||
} else if (action?.markChatAsReadAction) {
|
||||
@@ -796,7 +800,7 @@ export const processSyncAction = (
|
||||
{
|
||||
id,
|
||||
unreadCount: isNullUpdate ? null : !!markReadAction?.read ? 0 : -1,
|
||||
conditional: getChatUpdateConditional(id, markReadAction?.messageRange)
|
||||
conditional: getChatUpdateConditional(id!, markReadAction?.messageRange)
|
||||
}
|
||||
])
|
||||
} else if (action?.deleteMessageForMeAction || type === 'deleteMessageForMe') {
|
||||
@@ -812,7 +816,7 @@ export const processSyncAction = (
|
||||
} else if (action?.contactAction) {
|
||||
ev.emit('contacts.upsert', [
|
||||
{
|
||||
id: id,
|
||||
id: id!,
|
||||
name: action.contactAction.fullName!,
|
||||
lid: action.contactAction.lidJid || undefined,
|
||||
jid: isJidUser(id) ? id : undefined
|
||||
@@ -828,7 +832,7 @@ export const processSyncAction = (
|
||||
{
|
||||
id,
|
||||
pinned: action.pinAction?.pinned ? toNumber(action.timestamp) : null,
|
||||
conditional: getChatUpdateConditional(id, undefined)
|
||||
conditional: getChatUpdateConditional(id!, undefined)
|
||||
}
|
||||
])
|
||||
} else if (action?.unarchiveChatsSetting) {
|
||||
@@ -853,13 +857,13 @@ export const processSyncAction = (
|
||||
])
|
||||
} else if (action?.deleteChatAction || type === 'deleteChat') {
|
||||
if (!isInitialSync) {
|
||||
ev.emit('chats.delete', [id])
|
||||
ev.emit('chats.delete', [id!])
|
||||
}
|
||||
} else if (action?.labelEditAction) {
|
||||
const { name, color, deleted, predefinedId } = action.labelEditAction
|
||||
|
||||
ev.emit('labels.edit', {
|
||||
id,
|
||||
id: id!,
|
||||
name: name!,
|
||||
color: color!,
|
||||
deleted: deleted!,
|
||||
|
||||
Reference in New Issue
Block a user