summary refs log tree commit diff
path: root/api/src/util/Instance.ts
diff options
context:
space:
mode:
authoruurgothat <cckhmck@gmail.com>2021-10-17 21:49:46 +0300
committeruurgothat <cckhmck@gmail.com>2021-10-17 21:49:46 +0300
commit7dd18739625f69b7a0a0184911229bfe00f93deb (patch)
tree0a7f4079281ff348a9e365aa434e624927e29165 /api/src/util/Instance.ts
parentMerge branch 'master' of https://github.com/fosscord/fosscord-server (diff)
parentUpdate README.md (diff)
downloadserver-7dd18739625f69b7a0a0184911229bfe00f93deb.tar.xz
Merge branch 'master' of https://github.com/fosscord/fosscord-server
Diffstat (limited to '')
-rw-r--r--api/src/util/Instance.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/api/src/util/Instance.ts b/api/src/util/Instance.ts

index a7b3205a..6bddfa98 100644 --- a/api/src/util/Instance.ts +++ b/api/src/util/Instance.ts
@@ -1,4 +1,4 @@ -import { Config, Guild } from "@fosscord/util"; +import { Config, Guild, Session } from "@fosscord/util"; export async function initInstance() { // TODO: clean up database and delete tombstone data @@ -8,11 +8,14 @@ export async function initInstance() { // TODO: check if any current user is not part of autoJoinGuilds const { autoJoin } = Config.get().guild; - if (autoJoin.enabled && autoJoin.guilds?.length) { + if (autoJoin.enabled && !autoJoin.guilds?.length) { let guild = await Guild.findOne({}); - if (!guild) guild = await Guild.createGuild({}); - - // @ts-ignore - await Config.set({ guild: { autoJoin: { guilds: [guild.id] } } }); + if (guild) { + // @ts-ignore + await Config.set({ guild: { autoJoin: { guilds: [guild.id] } } }); + } } + + // TODO: do no clear sessions for instance cluster + await Session.delete({}); }