Skip to content

Commit f8f32d8

Browse files
committed
fix set/load key
1 parent df3db83 commit f8f32d8

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

src/services/client_baileys.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ export class ClientBaileys implements Client {
165165
// eslint-disable-next-line @typescript-eslint/no-explicit-any
166166
} catch (error: any) {
167167
logger.error(error, 'Erro on send status')
168-
await this.store?.dataStore?.setKey(id, waMessageKey)
169168
await this.onWebhookError(error)
170169
}
171170
} else {
@@ -211,7 +210,6 @@ export class ClientBaileys implements Client {
211210
await this.onWebhookError(error)
212211
}
213212
} else {
214-
await this.store?.dataStore?.setKey(id, waMessageKey)
215213
await this.listener.process(this.phone, [waMessage], 'qrcode')
216214
}
217215
}
@@ -326,7 +324,6 @@ export class ClientBaileys implements Client {
326324
}
327325
const messageCallsWebhook = this.config.rejectCallsWebhook || this.config.messageCallsWebhook
328326
if (messageCallsWebhook) {
329-
const id = uuid()
330327
const waMessageKey = {
331328
fromMe: false,
332329
id: uuid(),
@@ -338,7 +335,6 @@ export class ClientBaileys implements Client {
338335
conversation: messageCallsWebhook,
339336
},
340337
}
341-
await this.store?.dataStore?.setKey(id, waMessageKey)
342338
await this.listener.process(this.phone, [message], 'notify')
343339
}
344340
setTimeout(() => {

src/services/data_store_file.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,6 @@ const dataStoreFile = async (phone: string, config: Config): Promise<DataStore>
107107
}
108108
}
109109
})
110-
ev.on('messages.update', (updates: WAMessageUpdate[]) => {
111-
for (const update of updates) {
112-
const { key } = update
113-
if (key.id) {
114-
dataStore.setKey(key.id, key)
115-
}
116-
}
117-
})
118110
ev.on('contacts.upsert', async (contacts: Contact[]) => {
119111
logger.debug('contacts.upsert %s', phone, JSON.stringify(contacts))
120112
const { saveProfilePicture } = mediaStore

src/services/listener_baileys.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ export class ListenerBaileys implements Listener {
8989
const store = await config.getStore(phone, config)
9090
if (messageType && !['update', 'receipt'].includes(messageType)) {
9191
i = await config.getMessageMetadata(i)
92-
if (i.key && i.key.id) {
92+
if (i.key && i.key) {
9393
const idUno = uuid()
94-
const idBaileys = i.key.id
94+
const idBaileys = i.key.id!
9595
await store?.dataStore.setUnoId(idBaileys, idUno)
9696
await store?.dataStore.setKey(idUno, i.key)
97-
if (i.key.remoteJid) {
98-
await store.dataStore.setMessage(i.key.remoteJid, i)
99-
}
97+
await store?.dataStore.setKey(idBaileys, i.key)
98+
await store.dataStore.setMessage(i.key.remoteJid!, i)
10099
if (isSaveMedia(i)) {
101100
logger.debug(`Saving media...`)
102101
i = await store?.mediaStore.saveMedia(i)

0 commit comments

Comments
 (0)