Use async/await instead of explicit Promise
This commit is contained in:
parent
77a7397614
commit
fa4c555c44
@ -159,28 +159,26 @@ converse.plugins.add('converse-omemo', {
|
|||||||
}).then(() => this.buildSessions(devices))
|
}).then(() => this.buildSessions(devices))
|
||||||
},
|
},
|
||||||
|
|
||||||
buildSession (device) {
|
async buildSession (device) {
|
||||||
const { _converse } = this.__super__,
|
const { _converse } = this.__super__,
|
||||||
address = new libsignal.SignalProtocolAddress(device.get('jid'), device.get('id')),
|
address = new libsignal.SignalProtocolAddress(device.get('jid'), device.get('id')),
|
||||||
sessionBuilder = new libsignal.SessionBuilder(_converse.omemo_store, address),
|
sessionBuilder = new libsignal.SessionBuilder(_converse.omemo_store, address),
|
||||||
prekey = device.getRandomPreKey();
|
prekey = device.getRandomPreKey(),
|
||||||
|
bundle = await device.getBundle();
|
||||||
|
|
||||||
return device.getBundle()
|
return sessionBuilder.processPreKey({
|
||||||
.then(bundle => {
|
'registrationId': parseInt(device.get('id'), 10),
|
||||||
return sessionBuilder.processPreKey({
|
'identityKey': u.base64ToArrayBuffer(bundle.identity_key),
|
||||||
'registrationId': parseInt(device.get('id'), 10),
|
'signedPreKey': {
|
||||||
'identityKey': u.base64ToArrayBuffer(bundle.identity_key),
|
'keyId': bundle.signed_prekey.id, // <Number>
|
||||||
'signedPreKey': {
|
'publicKey': u.base64ToArrayBuffer(bundle.signed_prekey.public_key),
|
||||||
'keyId': bundle.signed_prekey.id, // <Number>
|
'signature': u.base64ToArrayBuffer(bundle.signed_prekey.signature)
|
||||||
'publicKey': u.base64ToArrayBuffer(bundle.signed_prekey.public_key),
|
},
|
||||||
'signature': u.base64ToArrayBuffer(bundle.signed_prekey.signature)
|
'preKey': {
|
||||||
},
|
'keyId': prekey.id, // <Number>
|
||||||
'preKey': {
|
'publicKey': u.base64ToArrayBuffer(prekey.key),
|
||||||
'keyId': prekey.id, // <Number>
|
}
|
||||||
'publicKey': u.base64ToArrayBuffer(prekey.key),
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getSession (device) {
|
getSession (device) {
|
||||||
|
Loading…
Reference in New Issue
Block a user