mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 12:19:41 +00:00
When incoming message should've been sealed sender, reply with profile key
This commit is contained in:
@@ -16,6 +16,8 @@ import { createBatcher } from './util/batcher';
|
||||
import { updateConversationsWithUuidLookup } from './updateConversationsWithUuidLookup';
|
||||
import { initializeAllJobQueues } from './jobs/initializeAllJobQueues';
|
||||
import { removeStorageKeyJobQueue } from './jobs/removeStorageKeyJobQueue';
|
||||
import { ourProfileKeyService } from './services/ourProfileKey';
|
||||
import { shouldRespondWithProfileKey } from './util/shouldRespondWithProfileKey';
|
||||
|
||||
const MAX_ATTACHMENT_DOWNLOAD_AGE = 3600 * 72 * 1000;
|
||||
|
||||
@@ -35,6 +37,8 @@ export async function startApp(): Promise<void> {
|
||||
|
||||
initializeAllJobQueues();
|
||||
|
||||
ourProfileKeyService.initialize(window.storage);
|
||||
|
||||
let resolveOnAppView: (() => void) | undefined;
|
||||
const onAppView = new Promise<void>(resolve => {
|
||||
resolveOnAppView = resolve;
|
||||
@@ -56,6 +60,10 @@ export async function startApp(): Promise<void> {
|
||||
concurrency: 1,
|
||||
timeout: 1000 * 60 * 2,
|
||||
});
|
||||
|
||||
const profileKeyResponseQueue = new window.PQueue();
|
||||
profileKeyResponseQueue.pause();
|
||||
|
||||
window.Whisper.deliveryReceiptQueue = new window.PQueue({
|
||||
concurrency: 1,
|
||||
timeout: 1000 * 60 * 2,
|
||||
@@ -1790,8 +1798,10 @@ export async function startApp(): Promise<void> {
|
||||
|
||||
connectCount += 1;
|
||||
|
||||
window.Whisper.deliveryReceiptQueue.pause(); // avoid flood of delivery receipts until we catch up
|
||||
window.Whisper.Notifications.disable(); // avoid notification flood until empty
|
||||
// To avoid a flood of operations before we catch up, we pause some queues.
|
||||
profileKeyResponseQueue.pause();
|
||||
window.Whisper.deliveryReceiptQueue.pause();
|
||||
window.Whisper.Notifications.disable();
|
||||
|
||||
// initialize the socket and start listening for messages
|
||||
window.log.info('Initializing socket and listening for messages');
|
||||
@@ -2112,6 +2122,7 @@ export async function startApp(): Promise<void> {
|
||||
newVersion
|
||||
);
|
||||
|
||||
profileKeyResponseQueue.start();
|
||||
window.Whisper.deliveryReceiptQueue.start();
|
||||
window.Whisper.Notifications.enable();
|
||||
|
||||
@@ -2183,6 +2194,7 @@ export async function startApp(): Promise<void> {
|
||||
// scenarios where we're coming back from sleep, we can get offline/online events
|
||||
// very fast, and it looks like a network blip. But we need to suppress
|
||||
// notifications in these scenarios too. So we listen for 'reconnect' events.
|
||||
profileKeyResponseQueue.pause();
|
||||
window.Whisper.deliveryReceiptQueue.pause();
|
||||
window.Whisper.Notifications.disable();
|
||||
}
|
||||
@@ -2366,7 +2378,7 @@ export async function startApp(): Promise<void> {
|
||||
// special case for syncing details about ourselves
|
||||
if (details.profileKey) {
|
||||
window.log.info('Got sync message with our own profile key');
|
||||
window.storage.put('profileKey', details.profileKey);
|
||||
ourProfileKeyService.set(details.profileKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2619,6 +2631,24 @@ export async function startApp(): Promise<void> {
|
||||
|
||||
const message = initIncomingMessage(data, messageDescriptor);
|
||||
|
||||
// We don't need this to interrupt our processing of the message, so we "fire and
|
||||
// forget".
|
||||
(async () => {
|
||||
if (await shouldRespondWithProfileKey(message)) {
|
||||
const contact = message.getContact();
|
||||
if (!contact) {
|
||||
assert(false, 'Expected message to have a contact');
|
||||
return;
|
||||
}
|
||||
|
||||
profileKeyResponseQueue.add(() => {
|
||||
contact.queueJob(() => contact.sendProfileKeyUpdate());
|
||||
});
|
||||
}
|
||||
})().catch(err => {
|
||||
window.log.error(err);
|
||||
});
|
||||
|
||||
if (data.message.reaction) {
|
||||
window.normalizeUuids(
|
||||
data.message.reaction,
|
||||
|
||||
Reference in New Issue
Block a user