Receive support for DOE messages
This commit is contained in:
parent
b8a674bbb6
commit
ba5e2ff6e5
17 changed files with 291 additions and 42 deletions
|
@ -600,6 +600,8 @@
|
|||
isTapToViewExpired: isTapToView && this.get('isErased'),
|
||||
isTapToViewError:
|
||||
isTapToView && this.isIncoming() && this.get('isTapToViewInvalid'),
|
||||
|
||||
deletedForEveryone: this.get('deletedForEveryone') || false,
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -1105,7 +1107,7 @@
|
|||
isErased() {
|
||||
return Boolean(this.get('isErased'));
|
||||
},
|
||||
async eraseContents() {
|
||||
async eraseContents(additionalProperties = {}) {
|
||||
if (this.get('isErased')) {
|
||||
return;
|
||||
}
|
||||
|
@ -1129,6 +1131,7 @@
|
|||
contact: [],
|
||||
sticker: null,
|
||||
preview: [],
|
||||
...additionalProperties,
|
||||
});
|
||||
this.trigger('content-changed');
|
||||
|
||||
|
@ -1442,12 +1445,17 @@
|
|||
const isOutgoing = this.get('type') === 'outgoing';
|
||||
const numDelivered = this.get('delivered');
|
||||
|
||||
// Case 1: We can reply if this is outgoing and delievered to at least one recipient
|
||||
// Case 1: We cannot reply if this message is deleted for everyone
|
||||
if (this.get('deletedForEveryone')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Case 2: We can reply if this is outgoing and delievered to at least one recipient
|
||||
if (isOutgoing && numDelivered > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Case 2: We can reply if there are no errors
|
||||
// Case 3: We can reply if there are no errors
|
||||
if (!errors || (errors && errors.length === 0)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -2457,6 +2465,11 @@
|
|||
message.handleReaction(reaction);
|
||||
});
|
||||
|
||||
// Does this message have any pending, previously-received associated
|
||||
// delete for everyone messages?
|
||||
const deletes = Whisper.Deletes.forMessage(message);
|
||||
deletes.forEach(del => Whisper.Deletes.onDelete(del));
|
||||
|
||||
Whisper.events.trigger('incrementProgress');
|
||||
confirm();
|
||||
} catch (error) {
|
||||
|
@ -2473,6 +2486,10 @@
|
|||
},
|
||||
|
||||
async handleReaction(reaction) {
|
||||
if (this.get('deletedForEveryone')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const reactions = this.get('reactions') || [];
|
||||
const messageId = this.idForLogging();
|
||||
const count = reactions.length;
|
||||
|
@ -2512,6 +2529,27 @@
|
|||
Message: Whisper.Message,
|
||||
});
|
||||
},
|
||||
|
||||
async handleDeleteForEveryone(del) {
|
||||
window.log.info('Handling DOE.', {
|
||||
fromId: del.get('fromId'),
|
||||
targetSentTimestamp: del.get('targetSentTimestamp'),
|
||||
messageServerTimestamp: this.get('serverTimestamp'),
|
||||
deleteServerTimestamp: del.get('serverTimestamp'),
|
||||
});
|
||||
|
||||
// Remove any notifications for this message
|
||||
const notificationForMessage = Whisper.Notifications.findWhere({
|
||||
messageId: this.get('id'),
|
||||
});
|
||||
Whisper.Notifications.remove(notificationForMessage);
|
||||
|
||||
// Erase the contents of this message
|
||||
await this.eraseContents({ deletedForEveryone: true, reactions: [] });
|
||||
|
||||
// Update the conversation's last message in case this was the last message
|
||||
this.getConversation().updateLastMessage();
|
||||
},
|
||||
});
|
||||
|
||||
// Receive will be enabled before we enable send
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue