MessageReceiver: Emit envelope event on queue for cached+decrypted items

This commit is contained in:
Scott Nonnenberg 2023-07-05 16:16:17 -07:00 committed by GitHub
parent 3bf8adf6e1
commit 8177a4e2b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 13 deletions

View file

@ -83,7 +83,8 @@ import type {
ConfigurationEvent,
DecryptionErrorEvent,
DeliveryEvent,
EnvelopeEvent,
EnvelopeQueuedEvent,
EnvelopeUnsealedEvent,
ErrorEvent,
FetchLatestEvent,
GroupEvent,
@ -339,8 +340,12 @@ export async function startApp(): Promise<void> {
}
messageReceiver.addEventListener(
'envelope',
queuedEventListener(onEnvelopeReceived, false)
'envelopeUnsealed',
queuedEventListener(onEnvelopeUnsealed, false)
);
messageReceiver.addEventListener(
'envelopeQueued',
queuedEventListener(onEnvelopeQueued, false)
);
messageReceiver.addEventListener(
'message',
@ -2430,9 +2435,15 @@ export async function startApp(): Promise<void> {
{ leading: false }
);
async function onEnvelopeReceived({
async function onEnvelopeQueued({
envelope,
}: EnvelopeEvent): Promise<void> {
}: EnvelopeQueuedEvent): Promise<void> {
throttledSetInboxEnvelopeTimestamp(envelope.serverTimestamp);
}
async function onEnvelopeUnsealed({
envelope,
}: EnvelopeUnsealedEvent): Promise<void> {
throttledSetInboxEnvelopeTimestamp(envelope.serverTimestamp);
const ourUuid = window.textsecure.storage.user.getUuid()?.toString();
@ -2441,7 +2452,7 @@ export async function startApp(): Promise<void> {
window.ConversationController.maybeMergeContacts({
e164: envelope.source,
aci: envelope.sourceUuid,
reason: `onEnvelopeReceived(${envelope.timestamp})`,
reason: `onEnvelopeUnsealed(${envelope.timestamp})`,
});
if (mergePromises.length > 0) {