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 [];
|
return [];
|
||||||
},
|
},
|
||||||
onDelete(del) {
|
async onDelete(del) {
|
||||||
try {
|
try {
|
||||||
// The contact the delete message came from
|
// The conversation the deleted message was in; we have to find it in the database
|
||||||
const fromContact = ConversationController.get(del.get('fromId'));
|
// to to figure that out.
|
||||||
|
const targetConversation = await ConversationController.getConversationForTargetMessage(
|
||||||
|
del.get('fromId'),
|
||||||
|
del.get('targetSentTimestamp')
|
||||||
|
);
|
||||||
|
|
||||||
if (!fromContact) {
|
if (!targetConversation) {
|
||||||
window.log.info(
|
window.log.info(
|
||||||
'No contact for DOE',
|
'No target conversation for DOE',
|
||||||
del.get('fromId'),
|
del.get('fromId'),
|
||||||
del.get('targetSentTimestamp')
|
del.get('targetSentTimestamp')
|
||||||
);
|
);
|
||||||
|
@ -41,7 +45,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not await, since this can deadlock the queue
|
// Do not await, since this can deadlock the queue
|
||||||
fromContact.queueJob(async () => {
|
targetConversation.queueJob(async () => {
|
||||||
window.log.info('Handling DOE for', del.get('targetSentTimestamp'));
|
window.log.info('Handling DOE for', del.get('targetSentTimestamp'));
|
||||||
|
|
||||||
const messages = await window.Signal.Data.getMessagesBySentAt(
|
const messages = await window.Signal.Data.getMessagesBySentAt(
|
||||||
|
@ -51,16 +55,9 @@
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const targetMessage = messages.find(m => {
|
const targetMessage = messages.find(
|
||||||
const messageContact = m.getContact();
|
m => del.get('fromId') === m.getContactId()
|
||||||
|
);
|
||||||
if (!messageContact) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find messages which are from the same contact who sent the DOE
|
|
||||||
return messageContact.get('id') === fromContact.get('id');
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!targetMessage) {
|
if (!targetMessage) {
|
||||||
window.log.info(
|
window.log.info(
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
},
|
},
|
||||||
async onReaction(reaction) {
|
async onReaction(reaction) {
|
||||||
try {
|
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(
|
const targetConversation = await ConversationController.getConversationForTargetMessage(
|
||||||
ConversationController.ensureContactIds({
|
ConversationController.ensureContactIds({
|
||||||
e164: reaction.get('targetAuthorE164'),
|
e164: reaction.get('targetAuthorE164'),
|
||||||
|
@ -54,7 +56,7 @@
|
||||||
);
|
);
|
||||||
if (!targetConversation) {
|
if (!targetConversation) {
|
||||||
window.log.info(
|
window.log.info(
|
||||||
'No contact for reaction',
|
'No target conversation for reaction',
|
||||||
reaction.get('targetAuthorE164'),
|
reaction.get('targetAuthorE164'),
|
||||||
reaction.get('targetAuthorUuid'),
|
reaction.get('targetAuthorUuid'),
|
||||||
reaction.get('targetTimestamp')
|
reaction.get('targetTimestamp')
|
||||||
|
|
|
@ -610,16 +610,7 @@ export class ConversationController {
|
||||||
const messages = await getMessagesBySentAt(targetTimestamp, {
|
const messages = await getMessagesBySentAt(targetTimestamp, {
|
||||||
MessageCollection: window.Whisper.MessageCollection,
|
MessageCollection: window.Whisper.MessageCollection,
|
||||||
});
|
});
|
||||||
const targetMessage = messages.find(m => {
|
const targetMessage = messages.find(m => m.getContactId() === targetFromId);
|
||||||
const contact = m.getContact();
|
|
||||||
|
|
||||||
if (!contact) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const mcid = contact.get('id');
|
|
||||||
return mcid === targetFromId;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (targetMessage) {
|
if (targetMessage) {
|
||||||
return targetMessage.getConversation();
|
return targetMessage.getConversation();
|
||||||
|
|
|
@ -2607,6 +2607,12 @@ type WhatIsThis = typeof window.WhatIsThis;
|
||||||
const message = initIncomingMessage(data, messageDescriptor);
|
const message = initIncomingMessage(data, messageDescriptor);
|
||||||
|
|
||||||
if (data.message.reaction) {
|
if (data.message.reaction) {
|
||||||
|
window.normalizeUuids(
|
||||||
|
data.message.reaction,
|
||||||
|
['targetAuthorUuid'],
|
||||||
|
'background::onMessageReceived'
|
||||||
|
);
|
||||||
|
|
||||||
const { reaction } = data.message;
|
const { reaction } = data.message;
|
||||||
window.log.info(
|
window.log.info(
|
||||||
'Queuing incoming reaction for',
|
'Queuing incoming reaction for',
|
||||||
|
@ -2814,6 +2820,12 @@ type WhatIsThis = typeof window.WhatIsThis;
|
||||||
const message = createSentMessage(data, messageDescriptor);
|
const message = createSentMessage(data, messageDescriptor);
|
||||||
|
|
||||||
if (data.message.reaction) {
|
if (data.message.reaction) {
|
||||||
|
window.normalizeUuids(
|
||||||
|
data.message.reaction,
|
||||||
|
['targetAuthorUuid'],
|
||||||
|
'background::onSentMessage'
|
||||||
|
);
|
||||||
|
|
||||||
const { reaction } = data.message;
|
const { reaction } = data.message;
|
||||||
window.log.info('Queuing sent reaction for', reaction.targetTimestamp);
|
window.log.info('Queuing sent reaction for', reaction.targetTimestamp);
|
||||||
const reactionModel = window.Whisper.Reactions.add({
|
const reactionModel = window.Whisper.Reactions.add({
|
||||||
|
|
Loading…
Add table
Reference in a new issue