DRY up early receipt processing
// FREEBIE
This commit is contained in:
parent
67900753d1
commit
f9a3c7817e
1 changed files with 12 additions and 20 deletions
|
@ -305,29 +305,21 @@
|
|||
}
|
||||
if (type === 'outgoing') {
|
||||
// lazy hack - check for receipts that arrived early.
|
||||
var recipients;
|
||||
if (dataMessage.group && dataMessage.group.id) { // group sync
|
||||
var members = conversation.get('members') || [];
|
||||
var receipts = window.receipts.where({ timestamp: timestamp });
|
||||
for (var i in receipts) {
|
||||
if (members.indexOf(receipts[i].get('source')) > -1) {
|
||||
window.receipts.remove(receipts[i]);
|
||||
message.set({
|
||||
delivered: (message.get('delivered') || 0) + 1
|
||||
});
|
||||
}
|
||||
}
|
||||
recipients = conversation.get('members') || [];
|
||||
} else {
|
||||
var receipt = window.receipts.findWhere({
|
||||
timestamp: timestamp,
|
||||
source: conversationId
|
||||
});
|
||||
if (receipt) {
|
||||
window.receipts.remove(receipt);
|
||||
message.set({
|
||||
delivered: (message.get('delivered') || 0) + 1
|
||||
});
|
||||
}
|
||||
recipients = [ conversation.id ];
|
||||
}
|
||||
window.receipts.filter(function(receipt) {
|
||||
return (receipt.get('timestamp') === timestamp) &&
|
||||
(recipients.indexOf(receipt.get('source')) > -1);
|
||||
}).forEach(function(receipt) {
|
||||
window.receipts.remove(receipt);
|
||||
message.set({
|
||||
delivered: (message.get('delivered') || 0) + 1
|
||||
});
|
||||
});
|
||||
}
|
||||
attributes.active_at = now;
|
||||
if (type === 'incoming') {
|
||||
|
|
Loading…
Reference in a new issue