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

View file

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

View file

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