resetSession: Take both UUID and e164, use each correctly

This commit is contained in:
Scott Nonnenberg 2020-06-08 13:22:26 -07:00
parent ae47748720
commit acf95f4745
3 changed files with 13 additions and 9 deletions

View File

@ -1727,7 +1727,8 @@
message.send(
this.wrapSend(
textsecure.messaging.resetSession(
this.get('uuid') || this.get('e164'),
this.get('uuid'),
this.get('e164'),
now,
options
)

View File

@ -583,9 +583,9 @@
nonblockingApproval = false;
}
const identifer = textsecure.utils.unencodeNumber(encodedAddress)[0];
const identityRecord = this.getIdentityRecord(identifer);
const id = ConversationController.getConversationId(identifer);
const identifier = textsecure.utils.unencodeNumber(encodedAddress)[0];
const identityRecord = this.getIdentityRecord(identifier);
const id = ConversationController.getConversationId(identifier);
if (!identityRecord || !identityRecord.publicKey) {
// Lookup failed, or the current key was removed, so save this one.
@ -626,7 +626,7 @@
});
try {
this.trigger('keychange', identifer);
this.trigger('keychange', identifier);
} catch (error) {
window.log.error(
'saveIdentity error triggering keychange:',

View File

@ -1221,7 +1221,8 @@ export default class MessageSender {
}
async resetSession(
identifier: string,
uuid: string,
e164: string,
timestamp: number,
options?: SendOptionsType
) {
@ -1232,6 +1233,8 @@ export default class MessageSender {
proto.flags = window.textsecure.protobuf.DataMessage.Flags.END_SESSION;
proto.timestamp = timestamp;
const identifier = e164 || uuid;
const logError = (prefix: string) => (error: Error) => {
window.log.error(prefix, error && error.stack ? error.stack : error);
throw error;
@ -1279,7 +1282,7 @@ export default class MessageSender {
const myNumber = window.textsecure.storage.user.getNumber();
const myUuid = window.textsecure.storage.user.getUuid();
// We already sent the reset session to our other devices in the code above!
if (identifier === myNumber || identifier === myUuid) {
if (e164 === myNumber || uuid === myUuid) {
return sendToContactPromise;
}
@ -1287,8 +1290,8 @@ export default class MessageSender {
const sendSyncPromise = this.sendSyncMessage(
buffer,
timestamp,
identifier,
null,
e164,
uuid,
null,
[],
[],