signal-desktop/ts/jobs/initializeAllJobQueues.ts

60 lines
1.9 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2021 Signal Messenger, LLC
2021-04-29 23:02:27 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import type { WebAPIType } from '../textsecure/WebAPI';
import { drop } from '../util/drop';
import { CallLinkDeleteManager } from './CallLinkDeleteManager';
2022-02-16 18:36:21 +00:00
import { conversationJobQueue } from './conversationJobQueue';
2024-06-24 18:38:59 +00:00
import { groupAvatarJobQueue } from './groupAvatarJobQueue';
import { readSyncJobQueue } from './readSyncJobQueue';
2021-04-29 23:02:27 +00:00
import { removeStorageKeyJobQueue } from './removeStorageKeyJobQueue';
import { reportSpamJobQueue } from './reportSpamJobQueue';
import { singleProtoJobQueue } from './singleProtoJobQueue';
import { viewOnceOpenJobQueue } from './viewOnceOpenJobQueue';
import { viewSyncJobQueue } from './viewSyncJobQueue';
2021-04-29 23:02:27 +00:00
/**
* Start all of the job queues. Should be called when the database is ready.
*/
export function initializeAllJobQueues({
server,
}: {
server: WebAPIType;
}): void {
reportSpamJobQueue.initialize({ server });
// General conversation send queue
drop(conversationJobQueue.streamJobs());
2024-06-24 18:38:59 +00:00
// Group avatar download after backup import
drop(groupAvatarJobQueue.streamJobs());
// Single proto send queue, used for a variety of one-off simple messages
drop(singleProtoJobQueue.streamJobs());
// Syncs to ourselves
drop(readSyncJobQueue.streamJobs());
drop(viewSyncJobQueue.streamJobs());
drop(viewOnceOpenJobQueue.streamJobs());
// Other queues
drop(removeStorageKeyJobQueue.streamJobs());
drop(reportSpamJobQueue.streamJobs());
drop(CallLinkDeleteManager.start());
2021-04-29 23:02:27 +00:00
}
2023-02-24 19:03:17 +00:00
export async function shutdownAllJobQueues(): Promise<void> {
await Promise.allSettled([
conversationJobQueue.shutdown(),
2024-06-24 18:38:59 +00:00
groupAvatarJobQueue.shutdown(),
2023-02-24 19:03:17 +00:00
singleProtoJobQueue.shutdown(),
readSyncJobQueue.shutdown(),
viewSyncJobQueue.shutdown(),
viewOnceOpenJobQueue.shutdown(),
removeStorageKeyJobQueue.shutdown(),
reportSpamJobQueue.shutdown(),
CallLinkDeleteManager.stop(),
2023-02-24 19:03:17 +00:00
]);
}