Page MenuHomePhabricator

D10781.id35957.diff
No OneTemporary

D10781.id35957.diff

diff --git a/lib/types/store-ops-types.js b/lib/types/store-ops-types.js
--- a/lib/types/store-ops-types.js
+++ b/lib/types/store-ops-types.js
@@ -12,7 +12,10 @@
import type { ClientReportCreationRequest } from './report-types.js';
import type { ClientDBThreadInfo, ThreadStore } from './thread-types.js';
import type { UserInfos } from './user-types.js';
-import type { ClientDBKeyserverInfo } from '../ops/keyserver-store-ops.js';
+import type {
+ ClientDBKeyserverInfo,
+ ClientDBKeyserverStoreOperation,
+} from '../ops/keyserver-store-ops.js';
import type {
ClientDBMessageStoreOperation,
MessageStoreOperation,
@@ -44,6 +47,7 @@
+threadStoreOperations?: $ReadOnlyArray<ClientDBThreadStoreOperation>,
+messageStoreOperations?: $ReadOnlyArray<ClientDBMessageStoreOperation>,
+reportStoreOperations?: $ReadOnlyArray<ClientDBReportStoreOperation>,
+ +keyserverStoreOperations?: $ReadOnlyArray<ClientDBKeyserverStoreOperation>,
};
export type ClientDBStore = {
diff --git a/web/database/worker/process-operations.js b/web/database/worker/process-operations.js
--- a/web/database/worker/process-operations.js
+++ b/web/database/worker/process-operations.js
@@ -1,5 +1,6 @@
// @flow
+import type { ClientDBKeyserverStoreOperation } from 'lib/ops/keyserver-store-ops.js';
import type { ClientDBReportStoreOperation } from 'lib/ops/report-store-ops.js';
import type { ClientDBThreadStoreOperation } from 'lib/ops/thread-store-ops.js';
import type {
@@ -119,13 +120,48 @@
}
}
+function processKeyserverStoreOperations(
+ sqliteQueryExecutor: SQLiteQueryExecutor,
+ operations: $ReadOnlyArray<ClientDBKeyserverStoreOperation>,
+ module: EmscriptenModule,
+) {
+ for (const operation: ClientDBKeyserverStoreOperation of operations) {
+ try {
+ if (operation.type === 'remove_all_keyservers') {
+ sqliteQueryExecutor.removeAllKeyservers();
+ } else if (operation.type === 'remove_keyserver') {
+ const { id } = operation.payload;
+ sqliteQueryExecutor.removeKeyserver(id);
+ } else if (operation.type === 'replace_keyserver') {
+ const { id, keyserverInfo } = operation.payload;
+ sqliteQueryExecutor.replaceKeyserver({ id, keyserverInfo });
+ } else {
+ throw new Error('Unsupported keyserver operation');
+ }
+ } catch (e) {
+ throw new Error(
+ `Error while processing ${
+ operation.type
+ } keyserver operation: ${getProcessingStoreOpsExceptionMessage(
+ e,
+ module,
+ )}`,
+ );
+ }
+ }
+}
+
function processDBStoreOperations(
sqliteQueryExecutor: SQLiteQueryExecutor,
storeOperations: ClientDBStoreOperations,
module: EmscriptenModule,
) {
- const { draftStoreOperations, reportStoreOperations, threadStoreOperations } =
- storeOperations;
+ const {
+ draftStoreOperations,
+ reportStoreOperations,
+ threadStoreOperations,
+ keyserverStoreOperations,
+ } = storeOperations;
try {
sqliteQueryExecutor.beginTransaction();
@@ -150,6 +186,13 @@
module,
);
}
+ if (keyserverStoreOperations && keyserverStoreOperations.length > 0) {
+ processKeyserverStoreOperations(
+ sqliteQueryExecutor,
+ keyserverStoreOperations,
+ module,
+ );
+ }
sqliteQueryExecutor.commitTransaction();
} catch (e) {
sqliteQueryExecutor.rollbackTransaction();
@@ -170,7 +213,7 @@
messageStoreThreads: [],
reports: sqliteQueryExecutor.getAllReports(),
users: [],
- keyservers: [],
+ keyservers: sqliteQueryExecutor.getAllKeyservers(),
};
}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 27, 12:00 PM (8 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2713176
Default Alt Text
D10781.id35957.diff (3 KB)

Event Timeline