Cleanup: Reactions, Delete for Everyone
This commit is contained in:
parent
e8759fc81b
commit
29eaa7b9a2
4 changed files with 29 additions and 27 deletions
|
@ -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(
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
},
|
||||
async onReaction(reaction) {
|
||||
try {
|
||||
// The conversation the target message was in; we have to find it in the database
|
||||
// to to figure that out.
|
||||
const targetConversation = await ConversationController.getConversationForTargetMessage(
|
||||
ConversationController.ensureContactIds({
|
||||
e164: reaction.get('targetAuthorE164'),
|
||||
|
@ -54,7 +56,7 @@
|
|||
);
|
||||
if (!targetConversation) {
|
||||
window.log.info(
|
||||
'No contact for reaction',
|
||||
'No target conversation for reaction',
|
||||
reaction.get('targetAuthorE164'),
|
||||
reaction.get('targetAuthorUuid'),
|
||||
reaction.get('targetTimestamp')
|
||||
|
|
|
@ -610,16 +610,7 @@ export class ConversationController {
|
|||
const messages = await getMessagesBySentAt(targetTimestamp, {
|
||||
MessageCollection: window.Whisper.MessageCollection,
|
||||
});
|
||||
const targetMessage = messages.find(m => {
|
||||
const contact = m.getContact();
|
||||
|
||||
if (!contact) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const mcid = contact.get('id');
|
||||
return mcid === targetFromId;
|
||||
});
|
||||
const targetMessage = messages.find(m => m.getContactId() === targetFromId);
|
||||
|
||||
if (targetMessage) {
|
||||
return targetMessage.getConversation();
|
||||
|
|
|
@ -2607,6 +2607,12 @@ type WhatIsThis = typeof window.WhatIsThis;
|
|||
const message = initIncomingMessage(data, messageDescriptor);
|
||||
|
||||
if (data.message.reaction) {
|
||||
window.normalizeUuids(
|
||||
data.message.reaction,
|
||||
['targetAuthorUuid'],
|
||||
'background::onMessageReceived'
|
||||
);
|
||||
|
||||
const { reaction } = data.message;
|
||||
window.log.info(
|
||||
'Queuing incoming reaction for',
|
||||
|
@ -2814,6 +2820,12 @@ type WhatIsThis = typeof window.WhatIsThis;
|
|||
const message = createSentMessage(data, messageDescriptor);
|
||||
|
||||
if (data.message.reaction) {
|
||||
window.normalizeUuids(
|
||||
data.message.reaction,
|
||||
['targetAuthorUuid'],
|
||||
'background::onSentMessage'
|
||||
);
|
||||
|
||||
const { reaction } = data.message;
|
||||
window.log.info('Queuing sent reaction for', reaction.targetTimestamp);
|
||||
const reactionModel = window.Whisper.Reactions.add({
|
||||
|
|
Loading…
Add table
Reference in a new issue