Passive UUID fixes
This commit is contained in:
parent
e7a01f8270
commit
37ad95af27
9 changed files with 80 additions and 40 deletions
|
@ -1229,7 +1229,7 @@
|
||||||
).map(contact => {
|
).map(contact => {
|
||||||
const error = new Error('Network is not available');
|
const error = new Error('Network is not available');
|
||||||
error.name = 'SendMessageNetworkError';
|
error.name = 'SendMessageNetworkError';
|
||||||
error.number = contact.get('uuid') || contact.get('e164');
|
error.identifier = contact.get('uuid') || contact.get('e164');
|
||||||
return error;
|
return error;
|
||||||
});
|
});
|
||||||
await message.saveErrors(errors);
|
await message.saveErrors(errors);
|
||||||
|
|
|
@ -264,7 +264,9 @@
|
||||||
|
|
||||||
// If an error has a specific number it's associated with, we'll show it next to
|
// If an error has a specific number it's associated with, we'll show it next to
|
||||||
// that contact. Otherwise, it will be a standalone entry.
|
// that contact. Otherwise, it will be a standalone entry.
|
||||||
const errors = _.reject(allErrors, error => Boolean(error.number));
|
const errors = _.reject(allErrors, error =>
|
||||||
|
Boolean(error.identifer || error.number)
|
||||||
|
);
|
||||||
const errorsGroupedById = _.groupBy(allErrors, 'number');
|
const errorsGroupedById = _.groupBy(allErrors, 'number');
|
||||||
const finalContacts = (conversationIds || []).map(id => {
|
const finalContacts = (conversationIds || []).map(id => {
|
||||||
const errorsForContact = errorsGroupedById[id];
|
const errorsForContact = errorsGroupedById[id];
|
||||||
|
@ -1264,16 +1266,27 @@
|
||||||
this.set({ errors: null });
|
this.set({ errors: null });
|
||||||
|
|
||||||
const conversation = this.getConversation();
|
const conversation = this.getConversation();
|
||||||
const intendedRecipients = this.get('recipients') || [];
|
const intendedRecipients = (this.get('recipients') || [])
|
||||||
const successfulRecipients = this.get('sent_to') || [];
|
.map(identifier => ConversationController.getConversationId(identifier))
|
||||||
const currentRecipients = conversation.getRecipients();
|
.filter(Boolean);
|
||||||
|
const successfulRecipients = (this.get('sent_to') || [])
|
||||||
|
.map(identifier => ConversationController.getConversationId(identifier))
|
||||||
|
.filter(Boolean);
|
||||||
|
const currentRecipients = conversation
|
||||||
|
.getRecipients()
|
||||||
|
.map(identifier => ConversationController.getConversationId(identifier))
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
const profileKey = conversation.get('profileSharing')
|
const profileKey = conversation.get('profileSharing')
|
||||||
? storage.get('profileKey')
|
? storage.get('profileKey')
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
// Determine retry recipients and get their most up-to-date addressing information
|
||||||
let recipients = _.intersection(intendedRecipients, currentRecipients);
|
let recipients = _.intersection(intendedRecipients, currentRecipients);
|
||||||
recipients = _.without(recipients, successfulRecipients);
|
recipients = _.without(recipients, successfulRecipients).map(id => {
|
||||||
|
const c = ConversationController.get(id);
|
||||||
|
return c.get('uuid') || c.get('e164');
|
||||||
|
});
|
||||||
|
|
||||||
if (!recipients.length) {
|
if (!recipients.length) {
|
||||||
window.log.warn('retrySend: Nobody to send to!');
|
window.log.warn('retrySend: Nobody to send to!');
|
||||||
|
@ -1297,7 +1310,10 @@
|
||||||
const stickerWithData = await loadStickerData(this.get('sticker'));
|
const stickerWithData = await loadStickerData(this.get('sticker'));
|
||||||
|
|
||||||
// Special-case the self-send case - we send only a sync message
|
// Special-case the self-send case - we send only a sync message
|
||||||
if (recipients.length === 1 && recipients[0] === this.OUR_NUMBER) {
|
if (
|
||||||
|
recipients.length === 1 &&
|
||||||
|
(recipients[0] === this.OUR_NUMBER || recipients[0] === this.OUR_UUID)
|
||||||
|
) {
|
||||||
const [identifier] = recipients;
|
const [identifier] = recipients;
|
||||||
const dataMessage = await textsecure.messaging.getMessageProto(
|
const dataMessage = await textsecure.messaging.getMessageProto(
|
||||||
identifier,
|
identifier,
|
||||||
|
@ -1348,7 +1364,7 @@
|
||||||
expireTimer: this.get('expireTimer'),
|
expireTimer: this.get('expireTimer'),
|
||||||
profileKey,
|
profileKey,
|
||||||
group: {
|
group: {
|
||||||
id: this.get('conversationId'),
|
id: this.getConversation().get('groupId'),
|
||||||
type: textsecure.protobuf.GroupContext.Type.DELIVER,
|
type: textsecure.protobuf.GroupContext.Type.DELIVER,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1429,13 +1445,14 @@
|
||||||
const { wrap, sendOptions } = ConversationController.prepareForSend(
|
const { wrap, sendOptions } = ConversationController.prepareForSend(
|
||||||
identifier
|
identifier
|
||||||
);
|
);
|
||||||
const promise = textsecure.messaging.sendMessageToNumber(
|
const promise = textsecure.messaging.sendMessageToIdentifier(
|
||||||
identifier,
|
identifier,
|
||||||
body,
|
body,
|
||||||
attachments,
|
attachments,
|
||||||
quoteWithData,
|
quoteWithData,
|
||||||
previewWithData,
|
previewWithData,
|
||||||
stickerWithData,
|
stickerWithData,
|
||||||
|
null,
|
||||||
this.get('sent_at'),
|
this.get('sent_at'),
|
||||||
this.get('expireTimer'),
|
this.get('expireTimer'),
|
||||||
profileKey,
|
profileKey,
|
||||||
|
@ -1444,11 +1461,15 @@
|
||||||
|
|
||||||
return this.send(wrap(promise));
|
return this.send(wrap(promise));
|
||||||
},
|
},
|
||||||
removeOutgoingErrors(number) {
|
removeOutgoingErrors(incomingIdentifier) {
|
||||||
|
const incomingConversationId = ConversationController.getConversationId(
|
||||||
|
incomingIdentifier
|
||||||
|
);
|
||||||
const errors = _.partition(
|
const errors = _.partition(
|
||||||
this.get('errors'),
|
this.get('errors'),
|
||||||
e =>
|
e =>
|
||||||
e.number === number &&
|
ConversationController.getConversationId(e.identifer || e.number) ===
|
||||||
|
incomingConversationId &&
|
||||||
(e.name === 'MessageError' ||
|
(e.name === 'MessageError' ||
|
||||||
e.name === 'OutgoingMessageError' ||
|
e.name === 'OutgoingMessageError' ||
|
||||||
e.name === 'SendMessageNetworkError' ||
|
e.name === 'SendMessageNetworkError' ||
|
||||||
|
@ -1535,7 +1556,9 @@
|
||||||
promises = promises.concat(
|
promises = promises.concat(
|
||||||
_.map(result.errors, error => {
|
_.map(result.errors, error => {
|
||||||
if (error.name === 'OutgoingIdentityKeyError') {
|
if (error.name === 'OutgoingIdentityKeyError') {
|
||||||
const c = ConversationController.get(error.number);
|
const c = ConversationController.get(
|
||||||
|
error.identifer || error.number
|
||||||
|
);
|
||||||
promises.push(c.getProfiles());
|
promises.push(c.getProfiles());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@ const { escapeRegExp } = require('lodash');
|
||||||
|
|
||||||
const APP_ROOT_PATH = path.join(__dirname, '..', '..', '..');
|
const APP_ROOT_PATH = path.join(__dirname, '..', '..', '..');
|
||||||
const PHONE_NUMBER_PATTERN = /\+\d{7,12}(\d{3})/g;
|
const PHONE_NUMBER_PATTERN = /\+\d{7,12}(\d{3})/g;
|
||||||
const UUID_PATTERN = /[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{10}([0-9A-F]{2})/gi;
|
const UUID_PATTERN = /[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{9}([0-9A-F]{3})/gi;
|
||||||
const GROUP_ID_PATTERN = /(group\()([^)]+)(\))/g;
|
const GROUP_ID_PATTERN = /(group\()([^)]+)(\))/g;
|
||||||
const REDACTION_PLACEHOLDER = '[REDACTED]';
|
const REDACTION_PLACEHOLDER = '[REDACTED]';
|
||||||
|
|
||||||
|
|
|
@ -2004,7 +2004,7 @@
|
||||||
await contact.setApproved();
|
await contact.setApproved();
|
||||||
}
|
}
|
||||||
|
|
||||||
message.resend(contact.get('e164'), contact.get('uuid'));
|
message.resend(contact.get('uuid') || contact.get('e164'));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -35,33 +35,38 @@
|
||||||
}
|
}
|
||||||
inherit(Error, ReplayableError);
|
inherit(Error, ReplayableError);
|
||||||
|
|
||||||
function IncomingIdentityKeyError(number, message, key) {
|
function IncomingIdentityKeyError(identifier, message, key) {
|
||||||
// eslint-disable-next-line prefer-destructuring
|
// eslint-disable-next-line prefer-destructuring
|
||||||
this.number = number.split('.')[0];
|
this.identifier = identifier.split('.')[0];
|
||||||
this.identityKey = key;
|
this.identityKey = key;
|
||||||
|
|
||||||
ReplayableError.call(this, {
|
ReplayableError.call(this, {
|
||||||
name: 'IncomingIdentityKeyError',
|
name: 'IncomingIdentityKeyError',
|
||||||
message: `The identity of ${this.number} has changed.`,
|
message: `The identity of ${this.identifier} has changed.`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
inherit(ReplayableError, IncomingIdentityKeyError);
|
inherit(ReplayableError, IncomingIdentityKeyError);
|
||||||
|
|
||||||
function OutgoingIdentityKeyError(number, message, timestamp, identityKey) {
|
function OutgoingIdentityKeyError(
|
||||||
|
identifier,
|
||||||
|
message,
|
||||||
|
timestamp,
|
||||||
|
identityKey
|
||||||
|
) {
|
||||||
// eslint-disable-next-line prefer-destructuring
|
// eslint-disable-next-line prefer-destructuring
|
||||||
this.number = number.split('.')[0];
|
this.identifier = identifier.split('.')[0];
|
||||||
this.identityKey = identityKey;
|
this.identityKey = identityKey;
|
||||||
|
|
||||||
ReplayableError.call(this, {
|
ReplayableError.call(this, {
|
||||||
name: 'OutgoingIdentityKeyError',
|
name: 'OutgoingIdentityKeyError',
|
||||||
message: `The identity of ${this.number} has changed.`,
|
message: `The identity of ${this.identifier} has changed.`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
inherit(ReplayableError, OutgoingIdentityKeyError);
|
inherit(ReplayableError, OutgoingIdentityKeyError);
|
||||||
|
|
||||||
function OutgoingMessageError(number, message, timestamp, httpError) {
|
function OutgoingMessageError(identifier, message, timestamp, httpError) {
|
||||||
// eslint-disable-next-line prefer-destructuring
|
// eslint-disable-next-line prefer-destructuring
|
||||||
this.number = number.split('.')[0];
|
this.identifier = identifier.split('.')[0];
|
||||||
|
|
||||||
ReplayableError.call(this, {
|
ReplayableError.call(this, {
|
||||||
name: 'OutgoingMessageError',
|
name: 'OutgoingMessageError',
|
||||||
|
@ -75,8 +80,9 @@
|
||||||
}
|
}
|
||||||
inherit(ReplayableError, OutgoingMessageError);
|
inherit(ReplayableError, OutgoingMessageError);
|
||||||
|
|
||||||
function SendMessageNetworkError(number, jsonData, httpError) {
|
function SendMessageNetworkError(identifier, jsonData, httpError) {
|
||||||
this.number = number;
|
// eslint-disable-next-line prefer-destructuring
|
||||||
|
this.identifier = identifier.split('.')[0];
|
||||||
this.code = httpError.code;
|
this.code = httpError.code;
|
||||||
|
|
||||||
ReplayableError.call(this, {
|
ReplayableError.call(this, {
|
||||||
|
@ -108,7 +114,7 @@
|
||||||
}
|
}
|
||||||
inherit(ReplayableError, MessageError);
|
inherit(ReplayableError, MessageError);
|
||||||
|
|
||||||
function UnregisteredUserError(number, httpError) {
|
function UnregisteredUserError(identifier, httpError) {
|
||||||
this.message = httpError.message;
|
this.message = httpError.message;
|
||||||
this.name = 'UnregisteredUserError';
|
this.name = 'UnregisteredUserError';
|
||||||
|
|
||||||
|
@ -120,7 +126,7 @@
|
||||||
Error.captureStackTrace(this);
|
Error.captureStackTrace(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.number = number;
|
this.identifier = identifier;
|
||||||
this.code = httpError.code;
|
this.code = httpError.code;
|
||||||
|
|
||||||
appendStack(this, httpError);
|
appendStack(this, httpError);
|
||||||
|
|
|
@ -242,7 +242,12 @@ MessageReceiver.prototype.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
envelope.id = envelope.serverGuid || window.getGuid();
|
// Make non-private envelope IDs dashless so they don't get redacted
|
||||||
|
// from logs
|
||||||
|
envelope.id = (envelope.serverGuid || window.getGuid()).replace(
|
||||||
|
/-/g,
|
||||||
|
''
|
||||||
|
);
|
||||||
envelope.serverTimestamp = envelope.serverTimestamp
|
envelope.serverTimestamp = envelope.serverTimestamp
|
||||||
? envelope.serverTimestamp.toNumber()
|
? envelope.serverTimestamp.toNumber()
|
||||||
: null;
|
: null;
|
||||||
|
@ -550,12 +555,17 @@ MessageReceiver.prototype.extend({
|
||||||
const promise = this.addToQueue(taskWithTimeout);
|
const promise = this.addToQueue(taskWithTimeout);
|
||||||
|
|
||||||
return promise.catch(error => {
|
return promise.catch(error => {
|
||||||
window.log.error(
|
const args = [
|
||||||
'queueEnvelope error handling envelope',
|
'queueEnvelope error handling envelope',
|
||||||
this.getEnvelopeId(envelope),
|
this.getEnvelopeId(envelope),
|
||||||
':',
|
':',
|
||||||
error && error.stack ? error.stack : error
|
error && error.stack ? error.stack : error,
|
||||||
);
|
];
|
||||||
|
if (error.warn) {
|
||||||
|
window.log.warn(...args);
|
||||||
|
} else {
|
||||||
|
window.log.error(...args);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// Same as handleEnvelope, just without the decryption step. Necessary for handling
|
// Same as handleEnvelope, just without the decryption step. Necessary for handling
|
||||||
|
@ -1418,9 +1428,12 @@ MessageReceiver.prototype.extend({
|
||||||
decrypted.group.members = [];
|
decrypted.group.members = [];
|
||||||
decrypted.group.avatar = null;
|
decrypted.group.avatar = null;
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
this.removeFromCache(envelope);
|
this.removeFromCache(envelope);
|
||||||
throw new Error('Unknown group message type');
|
const err = new Error('Unknown group message type');
|
||||||
|
err.warn = true;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,6 @@ OutgoingMessage.prototype = {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-param-reassign
|
|
||||||
error.number = identifier;
|
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
error.reason = reason;
|
error.reason = reason;
|
||||||
this.errors[this.errors.length] = error;
|
this.errors[this.errors.length] = error;
|
||||||
|
|
|
@ -29,8 +29,8 @@ describe('Privacy', () => {
|
||||||
|
|
||||||
const actual = Privacy.redactUuids(text);
|
const actual = Privacy.redactUuids(text);
|
||||||
const expected =
|
const expected =
|
||||||
'This is a log line with a uuid [REDACTED]b4\n' +
|
'This is a log line with a uuid [REDACTED]6b4\n' +
|
||||||
'and another one IN ALL UPPERCASE [REDACTED]A3';
|
'and another one IN ALL UPPERCASE [REDACTED]CA3';
|
||||||
assert.equal(actual, expected);
|
assert.equal(actual, expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1235,17 +1235,17 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "libtextsecure/message_receiver.js",
|
"path": "libtextsecure/message_receiver.js",
|
||||||
"line": " const buffer = dcodeIO.ByteBuffer.wrap(ciphertext);",
|
"line": " const buffer = dcodeIO.ByteBuffer.wrap(ciphertext);",
|
||||||
"lineNumber": 812,
|
"lineNumber": 822,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-03-04T21:24:23.269Z"
|
"updated": "2020-03-20T17:24:11.472Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "libtextsecure/message_receiver.js",
|
"path": "libtextsecure/message_receiver.js",
|
||||||
"line": " const buffer = dcodeIO.ByteBuffer.wrap(ciphertext);",
|
"line": " const buffer = dcodeIO.ByteBuffer.wrap(ciphertext);",
|
||||||
"lineNumber": 837,
|
"lineNumber": 847,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-03-04T21:24:23.269Z"
|
"updated": "2020-03-20T17:24:11.472Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
|
|
Loading…
Reference in a new issue