MCPcopy Create free account
hub / github.com/CommE2E/comm / createThreads

Function createThreads

keyserver/src/database/setup-db.js:478–518  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

476const createThreadOptions = { forceAddMembers: true };
477
478async function createThreads() {
479 const isAuthoritative = await isAuthoritativeKeyserver();
480
481 if (!isAuthoritative) {
482 return;
483 }
484
485 const insertIDsPromise = dbQuery(SQL`
486 INSERT INTO ids (id, table_name)
487 VALUES
488 (${genesis().id}, 'threads'),
489 (${bots.commbot.staffThreadID}, 'threads')
490 `);
491
492 const admin = await thisKeyserverAdmin();
493
494 const ashoatViewer = createScriptViewer(admin.id);
495 const createGenesisPromise = createThread(
496 ashoatViewer,
497 {
498 id: genesis().id,
499 type: threadTypes.GENESIS,
500 name: genesis().name,
501 description: genesis().description,
502 initialMemberIDs: [bots.commbot.userID],
503 },
504 createThreadOptions,
505 );
506 await Promise.all([insertIDsPromise, createGenesisPromise]);
507
508 const commbotViewer = createScriptViewer(bots.commbot.userID);
509 await createThread(
510 commbotViewer,
511 {
512 id: bots.commbot.staffThreadID,
513 type: threadTypes.COMMUNITY_SECRET_SUBTHREAD,
514 initialMemberIDs: [admin.id],
515 },
516 createThreadOptions,
517 );
518}
519
520async function setUpMetadataTable() {
521 await updateDBVersion(newDatabaseVersion);

Callers 1

setupDBFunction · 0.70

Calls 6

isAuthoritativeKeyserverFunction · 0.90
dbQueryFunction · 0.90
thisKeyserverAdminFunction · 0.90
createScriptViewerFunction · 0.90
createThreadFunction · 0.90
genesisFunction · 0.85

Tested by

no test coverage detected