diff --git a/app/http/endpoints/api/settings/updatesettings.go b/app/http/endpoints/api/settings/updatesettings.go
index 91a316e..9162578 100644
--- a/app/http/endpoints/api/settings/updatesettings.go
+++ b/app/http/endpoints/api/settings/updatesettings.go
@@ -119,6 +119,25 @@ func (s *Settings) Validate(guildId uint64) error {
}
})
+ group.Go(func() error {
+ if s.Settings.OverflowCategoryId != nil {
+ ch, ok := cache.Instance.GetChannel(*s.Settings.OverflowCategoryId)
+ if !ok {
+ return fmt.Errorf("Invalid overflow category")
+ }
+
+ if ch.GuildId != guildId {
+ return fmt.Errorf("Overflow category guild ID does not match")
+ }
+
+ if ch.Type != channel.ChannelTypeGuildCategory {
+ return fmt.Errorf("Overflow category is not a category")
+ }
+ }
+
+ return nil
+ })
+
return group.Wait()
}
diff --git a/frontend/src/components/manage/SettingsCard.svelte b/frontend/src/components/manage/SettingsCard.svelte
index 5d35038..f6ff01b 100644
--- a/frontend/src/components/manage/SettingsCard.svelte
+++ b/frontend/src/components/manage/SettingsCard.svelte
@@ -16,8 +16,19 @@
bind:value={data.welcome_message}/>
-
-
+
+
+
+
+
+ {#each channels as channel}
+ {#if channel.type === 4}
+
+ {/if}
+ {/each}
+
@@ -103,7 +114,7 @@
};
async function updateSettings() {
- // Svelte hack
+ // Svelte hack - I can't even remember what this does
let mapped = Object.fromEntries(Object.entries(data).map(([k, v]) => {
if (v === "null") {
return [k, null];
@@ -112,6 +123,18 @@
}
}));
+ // "Normalise" data.overflow_category_id
+ // Svelte doesn't always keep its promise of using integers, so == instead of ===
+ if (mapped.overflow_category_id == -1) {
+ mapped.overflow_enabled = false;
+ mapped.overflow_category_id = null;
+ } else if (mapped.overflow_category_id == -2) {
+ mapped.overflow_enabled = true
+ mapped.overflow_category_id = null;
+ } else {
+ mapped.overflow_enabled = true;
+ }
+
const res = await axios.post(`${API_URL}/api/${guildId}/settings`, mapped);
if (res.status === 200) {
if (showValidations(res.data)) {
@@ -184,6 +207,14 @@
data.category = first.id;
}
}
+
+ if (data.overflow_enabled === false) {
+ data.overflow_category_id = "-1";
+ } else if (data.overflow_enabled === true) {
+ if (data.overflow_category_id === null) {
+ data.overflow_category_id = "-2";
+ }
+ }
}
withLoadingScreen(async () => {
diff --git a/go.mod b/go.mod
index 8ea8834..82123c4 100644
--- a/go.mod
+++ b/go.mod
@@ -6,7 +6,7 @@ require (
github.com/BurntSushi/toml v0.3.1
github.com/TicketsBot/archiverclient v0.0.0-20210220155137-a562b2f1bbbb
github.com/TicketsBot/common v0.0.0-20210910205523-7ce93fba6fa5
- github.com/TicketsBot/database v0.0.0-20220209175741-201322cf97c9
+ github.com/TicketsBot/database v0.0.0-20220213185554-1b21129e2e3b
github.com/TicketsBot/worker v0.0.0-20211108224403-97ac8e44b789
github.com/apex/log v1.1.2
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
diff --git a/go.sum b/go.sum
index 31e1be9..db7d9a5 100644
--- a/go.sum
+++ b/go.sum
@@ -14,12 +14,12 @@ github.com/TicketsBot/common v0.0.0-20210910205523-7ce93fba6fa5/go.mod h1:SVwX6g
github.com/TicketsBot/database v0.0.0-20200516170158-fd8a949aec2c/go.mod h1:eky4tBL+IZ0svPgTT0N/9i6j7ygHDQH3784DW+HgfcA=
github.com/TicketsBot/database v0.0.0-20210902172951-4e1f8ced84b7/go.mod h1:A4T2uQFIWC/ttCYpfgv7AkPjR09mMRgzG13lgoV/+aI=
github.com/TicketsBot/database v0.0.0-20211108142700-c406ab0fc1bb/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
-github.com/TicketsBot/database v0.0.0-20211202174040-bd189305f898 h1:bbDirB6NmLjJ+9Zbw+Zy3073I7vRGxlKOb+jTRXm3vE=
-github.com/TicketsBot/database v0.0.0-20211202174040-bd189305f898/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
-github.com/TicketsBot/database v0.0.0-20220209175359-fa4c83cc47c5 h1:H1K2LqV+3LXYvD9atS5oOPJMLnBPREYsXSpIhib2HzQ=
-github.com/TicketsBot/database v0.0.0-20220209175359-fa4c83cc47c5/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
-github.com/TicketsBot/database v0.0.0-20220209175741-201322cf97c9 h1:n08Opi+1LFUP5O/B8wdScTJE3j4UWZxR2K1zEBorJpI=
-github.com/TicketsBot/database v0.0.0-20220209175741-201322cf97c9/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
+github.com/TicketsBot/database v0.0.0-20220213184807-16b6fe83ee5a h1:SfqC3eSlMmHbRWcOt4e34Foj3FGQVZv2sPCWkFn4hPQ=
+github.com/TicketsBot/database v0.0.0-20220213184807-16b6fe83ee5a/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
+github.com/TicketsBot/database v0.0.0-20220213185312-dc9f658164ba h1:22NdXBhrtyEWE8Pxe++Qn69WcPGjtsFNfBxpnTAVUzQ=
+github.com/TicketsBot/database v0.0.0-20220213185312-dc9f658164ba/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
+github.com/TicketsBot/database v0.0.0-20220213185554-1b21129e2e3b h1:yzEFTIygtUGRYqi92auS/mZbVR/Af03R0Jlf45TSN6I=
+github.com/TicketsBot/database v0.0.0-20220213185554-1b21129e2e3b/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
github.com/TicketsBot/logarchiver v0.0.0-20200423221245-a3f92edf8c14/go.mod h1:whts8TRxrAF4WuDuEAMllkWA/inKem0NhDEFeyuoOvE=
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM=
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261/go.mod h1:2zPxDAN2TAPpxUPjxszjs3QFKreKrQh5al/R3cMXmYk=