Move addCallHistory into conversation queue
This commit is contained in:
parent
59d158f968
commit
efda924589
1 changed files with 45 additions and 38 deletions
|
@ -3246,50 +3246,57 @@ export class ConversationModel extends window.Backbone
|
||||||
throw missingCaseError(callHistoryDetails);
|
throw missingCaseError(callHistoryDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
const message = {
|
// This is sometimes called inside of another conversation queue job so if
|
||||||
conversationId: this.id,
|
// awaited it would block on this forever.
|
||||||
type: 'call-history',
|
drop(
|
||||||
sent_at: timestamp,
|
this.queueJob('addCallHistory', async () => {
|
||||||
received_at:
|
const message = {
|
||||||
receivedAtCounter || window.Signal.Util.incrementMessageCounter(),
|
conversationId: this.id,
|
||||||
received_at_ms: timestamp,
|
type: 'call-history',
|
||||||
readStatus: unread ? ReadStatus.Unread : ReadStatus.Read,
|
sent_at: timestamp,
|
||||||
seenStatus: unread ? SeenStatus.Unseen : SeenStatus.NotApplicable,
|
received_at:
|
||||||
callHistoryDetails: detailsToSave,
|
receivedAtCounter || window.Signal.Util.incrementMessageCounter(),
|
||||||
// TODO: DESKTOP-722
|
received_at_ms: timestamp,
|
||||||
} as unknown as MessageAttributesType;
|
readStatus: unread ? ReadStatus.Unread : ReadStatus.Read,
|
||||||
|
seenStatus: unread ? SeenStatus.Unseen : SeenStatus.NotApplicable,
|
||||||
|
callHistoryDetails: detailsToSave,
|
||||||
|
// TODO: DESKTOP-722
|
||||||
|
} as unknown as MessageAttributesType;
|
||||||
|
|
||||||
if (callHistoryDetails.callMode === CallMode.Direct) {
|
if (callHistoryDetails.callMode === CallMode.Direct) {
|
||||||
const messageId = await window.Signal.Data.getCallHistoryMessageByCallId(
|
const messageId =
|
||||||
this.id,
|
await window.Signal.Data.getCallHistoryMessageByCallId(
|
||||||
callHistoryDetails.callId
|
this.id,
|
||||||
);
|
callHistoryDetails.callId
|
||||||
if (messageId != null) {
|
);
|
||||||
log.info(
|
if (messageId != null) {
|
||||||
`addCallHistory: Found existing call history message (Call ID ${callHistoryDetails.callId}, Message ID: ${messageId})`
|
log.info(
|
||||||
|
`addCallHistory: Found existing call history message (Call ID ${callHistoryDetails.callId}, Message ID: ${messageId})`
|
||||||
|
);
|
||||||
|
message.id = messageId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const id = await window.Signal.Data.saveMessage(message, {
|
||||||
|
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const model = window.MessageController.register(
|
||||||
|
id,
|
||||||
|
new window.Whisper.Message({
|
||||||
|
...message,
|
||||||
|
id,
|
||||||
|
})
|
||||||
);
|
);
|
||||||
message.id = messageId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const id = await window.Signal.Data.saveMessage(message, {
|
this.trigger('newmessage', model);
|
||||||
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
void this.updateUnread();
|
||||||
});
|
|
||||||
|
|
||||||
const model = window.MessageController.register(
|
if (canConversationBeUnarchived(this.attributes)) {
|
||||||
id,
|
this.setArchived(false);
|
||||||
new window.Whisper.Message({
|
}
|
||||||
...message,
|
|
||||||
id,
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this.trigger('newmessage', model);
|
|
||||||
void this.updateUnread();
|
|
||||||
|
|
||||||
if (canConversationBeUnarchived(this.attributes)) {
|
|
||||||
this.setArchived(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue