Resolve true if saveIdentity overwrote a key
Reflect whether a saveIdentity operation reflects a replacement of an existing key or not. The return value can be used by the caller to decide whether they should clear sessions for the recipient.
This commit is contained in:
parent
63d2536263
commit
ee00f080f4
@ -55,7 +55,16 @@ SignalProtocolStore.prototype = {
|
||||
saveIdentity: function(identifier, identityKey) {
|
||||
if (identifier === null || identifier === undefined)
|
||||
throw new Error("Tried to put identity key for undefined/null key");
|
||||
return Promise.resolve(this.put('identityKey' + identifier, identityKey));
|
||||
|
||||
var existing = this.get('identityKey' + identifier);
|
||||
this.put('identityKey' + identifier, identityKey)
|
||||
|
||||
if (existing && util.toString(identityKey) !== util.toString(existing)) {
|
||||
return Promise.resolve(true);
|
||||
} else {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/* Returns a prekeypair object or undefined */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user