Skip to content

Commit

Permalink
set/load message with same pattern jid
Browse files Browse the repository at this point in the history
  • Loading branch information
clairton committed Oct 21, 2023
1 parent 81cd0b3 commit 5bc5443
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unoapi-cloud",
"version": "1.3.6",
"version": "1.3.7",
"description": "Unoapi Cloud",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
12 changes: 4 additions & 8 deletions src/services/data_store_redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
isJidGroup,
} from '@whiskeysockets/baileys'
import { DataStore } from './data_store'
import { getMessageType, TYPE_MESSAGES_TO_PROCESS_FILE } from './transformer'
import { getMessageType, TYPE_MESSAGES_TO_PROCESS_FILE, jidToPhoneNumber, phoneNumberToJid } from './transformer'
import { getDataStore, dataStores } from './data_store'
import {
delAuth,
Expand Down Expand Up @@ -118,18 +118,14 @@ const dataStoreRedis = (phone: string, config: Config): DataStore => {
}
return jid || ''
}
dataStore.loadMessage = async (jid: string, id: string) => {
const split = jid.split('@')
const number = split[0].split(':')[0]
const newJid = `${number}@${split[1]}`
dataStore.loadMessage = async (remoteJid: string, id: string) => {
const newJid = isJidGroup(remoteJid) ? remoteJid : phoneNumberToJid(jidToPhoneNumber(remoteJid))
const m = await getMessage(phone, newJid, id)
const wm = m as proto.IWebMessageInfo
return wm
}
dataStore.setMessage = async (remoteJid: string, message: WAMessage) => {
const split = remoteJid.split('@')
const number = split[0].split(':')[0]
const newJid = `${number}@${split[1]}`
const newJid = isJidGroup(remoteJid) ? remoteJid : phoneNumberToJid(jidToPhoneNumber(remoteJid))
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return setMessage(phone, newJid, message.key.id!, message)
}
Expand Down

0 comments on commit 5bc5443

Please sign in to comment.