Cleanup: Reactions, Delete for Everyone

This commit is contained in:
Scott Nonnenberg 2020-11-02 14:49:07 -08:00 committed by GitHub
parent e8759fc81b
commit 29eaa7b9a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 27 deletions

View file

@ -25,14 +25,18 @@
return [];
},
onDelete(del) {
async onDelete(del) {
try {
// The contact the delete message came from
const fromContact = ConversationController.get(del.get('fromId'));
// The conversation the deleted message was in; we have to find it in the database
// to to figure that out.
const targetConversation = await ConversationController.getConversationForTargetMessage(
del.get('fromId'),
del.get('targetSentTimestamp')
);
if (!fromContact) {
if (!targetConversation) {
window.log.info(
'No contact for DOE',
'No target conversation for DOE',
del.get('fromId'),
del.get('targetSentTimestamp')
);
@ -41,7 +45,7 @@
}
// Do not await, since this can deadlock the queue
fromContact.queueJob(async () => {
targetConversation.queueJob(async () => {
window.log.info('Handling DOE for', del.get('targetSentTimestamp'));
const messages = await window.Signal.Data.getMessagesBySentAt(
@ -51,16 +55,9 @@
}
);
const targetMessage = messages.find(m => {
const messageContact = m.getContact();
if (!messageContact) {
return false;
}
// Find messages which are from the same contact who sent the DOE
return messageContact.get('id') === fromContact.get('id');
});
const targetMessage = messages.find(
m => del.get('fromId') === m.getContactId()
);
if (!targetMessage) {
window.log.info(