Page MenuHomePhabricator

D12227.id40683.diff
No OneTemporary

D12227.id40683.diff

diff --git a/keyserver/src/database/setup-db.js b/keyserver/src/database/setup-db.js
--- a/keyserver/src/database/setup-db.js
+++ b/keyserver/src/database/setup-db.js
@@ -6,6 +6,7 @@
import { sortUserIDs } from 'lib/shared/relationship-utils.js';
import { undirectedStatus } from 'lib/types/relationship-types.js';
import { threadTypes } from 'lib/types/thread-types-enum.js';
+import type { NewThreadResponse } from 'lib/types/thread-types.js';
import { createThread } from '../creators/thread-creator.js';
import { dbQuery, SQL } from '../database/database.js';
@@ -16,7 +17,11 @@
} from '../database/migration-config.js';
import { createScriptViewer } from '../session/scripts.js';
import { ensureUserCredentials } from '../user/checks.js';
-import { thisKeyserverAdmin, saveIdentityInfo } from '../user/identity.js';
+import {
+ thisKeyserverAdmin,
+ saveIdentityInfo,
+ isAuthoritativeKeyserver,
+} from '../user/identity.js';
import { verifyUserLoggedInWithoutDB } from '../user/login.js';
import { createPickledOlmAccount } from '../utils/olm-utils.js';
@@ -468,27 +473,31 @@
const createThreadOptions = { forceAddMembers: true };
async function createThreads() {
+ const shouldCreateGenesis = await isAuthoritativeKeyserver();
const insertIDsPromise = dbQuery(SQL`
INSERT INTO ids (id, table_name)
VALUES
- (${genesis().id}, 'threads'),
+ ${shouldCreateGenesis ? `(${genesis().id}, 'threads'),` : ''}
(${bots.commbot.staffThreadID}, 'threads')
`);
const admin = await thisKeyserverAdmin();
- const ashoatViewer = createScriptViewer(admin.id);
- const createGenesisPromise = createThread(
- ashoatViewer,
- {
- id: genesis().id,
- type: threadTypes.GENESIS,
- name: genesis().name,
- description: genesis().description,
- initialMemberIDs: [bots.commbot.userID],
- },
- createThreadOptions,
- );
+ const adminViewer = createScriptViewer(admin.id);
+ let createGenesisPromise: Promise<?NewThreadResponse> = Promise.resolve(null);
+ if (shouldCreateGenesis) {
+ createGenesisPromise = createThread(
+ adminViewer,
+ {
+ id: genesis().id,
+ type: threadTypes.GENESIS,
+ name: genesis().name,
+ description: genesis().description,
+ initialMemberIDs: [bots.commbot.userID],
+ },
+ createThreadOptions,
+ );
+ }
await Promise.all([insertIDsPromise, createGenesisPromise]);
const commbotViewer = createScriptViewer(bots.commbot.userID);

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 12:17 AM (21 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2577777
Default Alt Text
D12227.id40683.diff (2 KB)

Event Timeline