summary refs log tree commit diff
path: root/src/api/util/handlers/Instance.ts
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-15 11:13:21 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-15 11:13:21 +0200
commit1a94fb1208bf0e4c669cad16aff5f57dc0bf7a3c (patch)
tree1035116ddbaacc5fcc5ae250a6592eb88f78f75c /src/api/util/handlers/Instance.ts
parentDo the funny thing (make user->invite cascade delet) (diff)
parentchange dev panel path, we missed this one... (diff)
downloadserver-1a94fb1208bf0e4c669cad16aff5f57dc0bf7a3c.tar.xz
Merge branch 'dev/restructure' into staging
Diffstat (limited to 'src/api/util/handlers/Instance.ts')
-rw-r--r--src/api/util/handlers/Instance.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/api/util/handlers/Instance.ts b/src/api/util/handlers/Instance.ts
new file mode 100644

index 00000000..7c337270 --- /dev/null +++ b/src/api/util/handlers/Instance.ts
@@ -0,0 +1,22 @@ +import { Config, Guild, Session } from "@fosscord/util"; +import { createQueryBuilder } from "typeorm"; + +export async function initInstance() { + // TODO: clean up database and delete tombstone data + // TODO: set first user as instance administrator/or generate one if none exists and output it in the terminal + + // create default guild and add it to auto join + // TODO: check if any current user is not part of autoJoinGuilds + const { autoJoin } = Config.get().guild; + + if (autoJoin.enabled && !autoJoin.guilds?.length) { + let guild = await Guild.findOne({where: {}, order: {id: "ASC"}}); + if (guild) { + // @ts-ignore + await Config.set({ guild: { autoJoin: { guilds: [guild.id] } } }); + } + } + + // TODO: do no clear sessions for instance cluster + await Session.delete({}); +}