mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: use transaction when uploading prekeys
This commit is contained in:
@@ -60,6 +60,8 @@ export const makeSocket = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { creds } = authState
|
const { creds } = authState
|
||||||
|
// add transaction capability
|
||||||
|
const keys = addTransactionCapability(authState.keys, logger)
|
||||||
|
|
||||||
let lastDateRecv: Date
|
let lastDateRecv: Date
|
||||||
let epoch = 0
|
let epoch = 0
|
||||||
@@ -230,10 +232,14 @@ export const makeSocket = ({
|
|||||||
update.serverHasPreKeys = true
|
update.serverHasPreKeys = true
|
||||||
}
|
}
|
||||||
|
|
||||||
await authState.keys.set({ 'pre-key': newPreKeys })
|
await keys.transaction(
|
||||||
|
async() => {
|
||||||
|
await keys.set({ 'pre-key': newPreKeys })
|
||||||
|
|
||||||
const preKeys = await getPreKeys(authState.keys, preKeysRange[0], preKeysRange[0] + preKeysRange[1])
|
const preKeys = await getPreKeys(keys, preKeysRange[0], preKeysRange[0] + preKeysRange[1])
|
||||||
await execute(preKeys)
|
await execute(preKeys)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
ev.emit('creds.update', update)
|
ev.emit('creds.update', update)
|
||||||
}
|
}
|
||||||
@@ -574,11 +580,7 @@ export const makeSocket = ({
|
|||||||
type: 'md' as 'md',
|
type: 'md' as 'md',
|
||||||
ws,
|
ws,
|
||||||
ev,
|
ev,
|
||||||
authState: {
|
authState: { creds, keys },
|
||||||
creds,
|
|
||||||
// add capability
|
|
||||||
keys: addTransactionCapability(authState.keys, logger)
|
|
||||||
},
|
|
||||||
get user() {
|
get user() {
|
||||||
return authState.creds.me
|
return authState.creds.me
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user