mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: add state sync keys in transaction
This commit is contained in:
@@ -168,15 +168,18 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
const keys = protocolMsg.appStateSyncKeyShare!.keys
|
||||
if(keys?.length) {
|
||||
let newAppStateSyncKeyId = ''
|
||||
for(const { keyData, keyId } of keys) {
|
||||
const strKeyId = Buffer.from(keyId.keyId!).toString('base64')
|
||||
await authState.keys.transaction(
|
||||
async() => {
|
||||
for(const { keyData, keyId } of keys) {
|
||||
const strKeyId = Buffer.from(keyId.keyId!).toString('base64')
|
||||
|
||||
logger.info({ strKeyId }, 'injecting new app state sync key')
|
||||
await authState.keys.set({ 'app-state-sync-key': { [strKeyId]: keyData } })
|
||||
|
||||
newAppStateSyncKeyId = strKeyId
|
||||
}
|
||||
logger.info({ strKeyId }, 'injecting new app state sync key')
|
||||
await authState.keys.set({ 'app-state-sync-key': { [strKeyId]: keyData } })
|
||||
|
||||
newAppStateSyncKeyId = strKeyId
|
||||
}
|
||||
}
|
||||
)
|
||||
ev.emit('creds.update', { myAppStateKeyId: newAppStateSyncKeyId })
|
||||
} else {
|
||||
logger.info({ protocolMsg }, 'recv app state sync with 0 keys')
|
||||
|
||||
Reference in New Issue
Block a user