Sync messages: Additional debugging info, consistent ids

This commit is contained in:
Scott Nonnenberg 2020-08-06 10:28:56 -07:00 committed by GitHub
parent 1227a51c99
commit b63291507a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 20 deletions

View file

@ -2815,13 +2815,21 @@
function onReadReceipt(ev) { function onReadReceipt(ev) {
const readAt = ev.timestamp; const readAt = ev.timestamp;
const { timestamp, source, sourceUuid } = ev.read; const { envelopeTimestamp, timestamp, source, sourceUuid } = ev.read;
const reader = ConversationController.ensureContactIds({ const reader = ConversationController.ensureContactIds({
e164: source, e164: source,
uuid: sourceUuid, uuid: sourceUuid,
highTrust: true, highTrust: true,
}); });
window.log.info('read receipt', timestamp, source, sourceUuid, reader); window.log.info(
'read receipt',
source,
sourceUuid,
envelopeTimestamp,
reader,
'for sent message',
timestamp
);
ev.confirm(); ev.confirm();
@ -2841,11 +2849,24 @@
function onReadSync(ev) { function onReadSync(ev) {
const readAt = ev.timestamp; const readAt = ev.timestamp;
const { timestamp } = ev.read; const { envelopeTimestamp, sender, senderUuid, timestamp } = ev.read;
const { sender, senderUuid } = ev.read; const senderId = ConversationController.ensureContactIds({
window.log.info('read sync', sender, senderUuid, timestamp); e164: sender,
uuid: senderUuid,
});
window.log.info(
'read sync',
sender,
senderUuid,
envelopeTimestamp,
senderId,
'for message',
timestamp
);
const receipt = Whisper.ReadSyncs.add({ const receipt = Whisper.ReadSyncs.add({
senderId,
sender, sender,
senderUuid, senderUuid,
timestamp, timestamp,
@ -2930,13 +2951,13 @@
function onDeliveryReceipt(ev) { function onDeliveryReceipt(ev) {
const { deliveryReceipt } = ev; const { deliveryReceipt } = ev;
const { sourceUuid, source } = deliveryReceipt; const {
envelopeTimestamp,
window.log.info( sourceUuid,
'delivery receipt from', source,
`${source} ${sourceUuid} ${deliveryReceipt.sourceDevice}`, sourceDevice,
deliveryReceipt.timestamp timestamp,
); } = deliveryReceipt;
ev.confirm(); ev.confirm();
@ -2946,13 +2967,24 @@
highTrust: true, highTrust: true,
}); });
window.log.info(
'delivery receipt from',
source,
sourceUuid,
sourceDevice,
deliveredTo,
envelopeTimestamp,
'for sent message',
timestamp
);
if (!deliveredTo) { if (!deliveredTo) {
window.log.info('no conversation for', source, sourceUuid); window.log.info('no conversation for', source, sourceUuid);
return; return;
} }
const receipt = Whisper.DeliveryReceipts.add({ const receipt = Whisper.DeliveryReceipts.add({
timestamp: deliveryReceipt.timestamp, timestamp,
deliveredTo, deliveredTo,
}); });

View file

@ -13,8 +13,12 @@
window.Whisper = window.Whisper || {}; window.Whisper = window.Whisper || {};
Whisper.ReadSyncs = new (Backbone.Collection.extend({ Whisper.ReadSyncs = new (Backbone.Collection.extend({
forMessage(message) { forMessage(message) {
const senderId = window.ConversationController.ensureContactIds({
e164: message.get('source'),
uuid: message.get('sourceUuid'),
});
const receipt = this.findWhere({ const receipt = this.findWhere({
sender: message.get('source'), senderId,
timestamp: message.get('sent_at'), timestamp: message.get('sent_at'),
}); });
if (receipt) { if (receipt) {
@ -34,12 +38,14 @@
} }
); );
const found = messages.find( const found = messages.find(item => {
item => const senderId = window.ConversationController.ensureContactIds({
item.isIncoming() && e164: item.get('source'),
(item.get('source') === receipt.get('sender') || uuid: item.get('sourceUuid'),
item.get('sourceUuid') === receipt.get('senderUuid')) });
);
return item.isIncoming() && senderId === receipt.get('senderId');
});
const notificationForMessage = found const notificationForMessage = found
? Whisper.Notifications.findWhere({ messageId: found.id }) ? Whisper.Notifications.findWhere({ messageId: found.id })
: null; : null;
@ -48,6 +54,7 @@
if (!found) { if (!found) {
window.log.info( window.log.info(
'No message for read sync', 'No message for read sync',
receipt.get('senderId'),
receipt.get('sender'), receipt.get('sender'),
receipt.get('senderUuid'), receipt.get('senderUuid'),
receipt.get('timestamp') receipt.get('timestamp')

View file

@ -1290,6 +1290,7 @@ class MessageReceiverInner extends EventTarget {
ev.confirm = this.removeFromCache.bind(this, envelope); ev.confirm = this.removeFromCache.bind(this, envelope);
ev.deliveryReceipt = { ev.deliveryReceipt = {
timestamp: receiptMessage.timestamp[i].toNumber(), timestamp: receiptMessage.timestamp[i].toNumber(),
envelopeTimestamp: envelope.timestamp.toNumber(),
source: envelope.source, source: envelope.source,
sourceUuid: envelope.sourceUuid, sourceUuid: envelope.sourceUuid,
sourceDevice: envelope.sourceDevice, sourceDevice: envelope.sourceDevice,
@ -1306,6 +1307,7 @@ class MessageReceiverInner extends EventTarget {
ev.timestamp = envelope.timestamp.toNumber(); ev.timestamp = envelope.timestamp.toNumber();
ev.read = { ev.read = {
timestamp: receiptMessage.timestamp[i].toNumber(), timestamp: receiptMessage.timestamp[i].toNumber(),
envelopeTimestamp: envelope.timestamp.toNumber(),
source: envelope.source, source: envelope.source,
sourceUuid: envelope.sourceUuid, sourceUuid: envelope.sourceUuid,
}; };
@ -1569,6 +1571,7 @@ class MessageReceiverInner extends EventTarget {
ev.confirm = this.removeFromCache.bind(this, envelope); ev.confirm = this.removeFromCache.bind(this, envelope);
ev.timestamp = envelope.timestamp.toNumber(); ev.timestamp = envelope.timestamp.toNumber();
ev.read = { ev.read = {
envelopeTimestamp: envelope.timestamp.toNumber(),
timestamp: read[i].timestamp.toNumber(), timestamp: read[i].timestamp.toNumber(),
sender: read[i].sender, sender: read[i].sender,
senderUuid: read[i].senderUuid, senderUuid: read[i].senderUuid,