add flag for toggling usage of alias subdomains

related to #160, requested by cryptix
This commit is contained in:
cblgh 2021-04-19 16:32:01 +02:00
parent 1c5c0b9867
commit 8d1f790f57
3 changed files with 35 additions and 28 deletions

View File

@ -4,6 +4,7 @@ CREATE TABLE config (
id integer NOT NULL PRIMARY KEY,
privacyMode integer NOT NULL, -- open, community, restricted
defaultLanguage TEXT NOT NULL, -- a language tag, e.g. en, sv, de
use_subdomain_for_aliases boolean NOT NULL, -- flag to toggle using subdomains (rather than alias routes) for aliases
CHECK (id == 0) -- should only ever store one row
);
@ -11,10 +12,11 @@ CREATE TABLE config (
-- the config table will only ever contain one row: the rooms current settings
-- we update that row whenever the config changes.
-- to have something to update, we insert the first and only row at id 0
INSERT INTO config (id, privacyMode, defaultLanguage) VALUES (
INSERT INTO config (id, privacyMode, defaultLanguage, use_subdomain_for_aliases) VALUES (
0, -- the constant id we will query
2, -- community is the default mode unless overridden
"en" -- english is the default language for all installs
"en", -- english is the default language for all installs
1 -- use subdomain for aliases
);
-- +migrate Down

View File

@ -23,22 +23,25 @@ import (
// Config is an object representing the database table.
type Config struct {
ID int64 `boil:"id" json:"id" toml:"id" yaml:"id"`
PrivacyMode roomdb.PrivacyMode `boil:"privacyMode" json:"privacyMode" toml:"privacyMode" yaml:"privacyMode"`
DefaultLanguage string `boil:"defaultLanguage" json:"defaultLanguage" toml:"defaultLanguage" yaml:"defaultLanguage"`
ID int64 `boil:"id" json:"id" toml:"id" yaml:"id"`
PrivacyMode roomdb.PrivacyMode `boil:"privacyMode" json:"privacyMode" toml:"privacyMode" yaml:"privacyMode"`
DefaultLanguage string `boil:"defaultLanguage" json:"defaultLanguage" toml:"defaultLanguage" yaml:"defaultLanguage"`
UseSubdomainForAliases bool `boil:"use_subdomain_for_aliases" json:"use_subdomain_for_aliases" toml:"use_subdomain_for_aliases" yaml:"use_subdomain_for_aliases"`
R *configR `boil:"-" json:"-" toml:"-" yaml:"-"`
L configL `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var ConfigColumns = struct {
ID string
PrivacyMode string
DefaultLanguage string
ID string
PrivacyMode string
DefaultLanguage string
UseSubdomainForAliases string
}{
ID: "id",
PrivacyMode: "privacyMode",
DefaultLanguage: "defaultLanguage",
ID: "id",
PrivacyMode: "privacyMode",
DefaultLanguage: "defaultLanguage",
UseSubdomainForAliases: "use_subdomain_for_aliases",
}
// Generated where
@ -64,14 +67,25 @@ func (w whereHelperroomdb_PrivacyMode) GTE(x roomdb.PrivacyMode) qm.QueryMod {
return qmhelper.Where(w.field, qmhelper.GTE, x)
}
type whereHelperbool struct{ field string }
func (w whereHelperbool) EQ(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.EQ, x) }
func (w whereHelperbool) NEQ(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.NEQ, x) }
func (w whereHelperbool) LT(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LT, x) }
func (w whereHelperbool) LTE(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LTE, x) }
func (w whereHelperbool) GT(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GT, x) }
func (w whereHelperbool) GTE(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GTE, x) }
var ConfigWhere = struct {
ID whereHelperint64
PrivacyMode whereHelperroomdb_PrivacyMode
DefaultLanguage whereHelperstring
ID whereHelperint64
PrivacyMode whereHelperroomdb_PrivacyMode
DefaultLanguage whereHelperstring
UseSubdomainForAliases whereHelperbool
}{
ID: whereHelperint64{field: "\"config\".\"id\""},
PrivacyMode: whereHelperroomdb_PrivacyMode{field: "\"config\".\"privacyMode\""},
DefaultLanguage: whereHelperstring{field: "\"config\".\"defaultLanguage\""},
ID: whereHelperint64{field: "\"config\".\"id\""},
PrivacyMode: whereHelperroomdb_PrivacyMode{field: "\"config\".\"privacyMode\""},
DefaultLanguage: whereHelperstring{field: "\"config\".\"defaultLanguage\""},
UseSubdomainForAliases: whereHelperbool{field: "\"config\".\"use_subdomain_for_aliases\""},
}
// ConfigRels is where relationship names are stored.
@ -91,8 +105,8 @@ func (*configR) NewStruct() *configR {
type configL struct{}
var (
configAllColumns = []string{"id", "privacyMode", "defaultLanguage"}
configColumnsWithoutDefault = []string{"privacyMode", "defaultLanguage"}
configAllColumns = []string{"id", "privacyMode", "defaultLanguage", "use_subdomain_for_aliases"}
configColumnsWithoutDefault = []string{"privacyMode", "defaultLanguage", "use_subdomain_for_aliases"}
configColumnsWithDefault = []string{"id"}
configPrimaryKeyColumns = []string{"id"}
)

View File

@ -48,15 +48,6 @@ var InviteColumns = struct {
// Generated where
type whereHelperbool struct{ field string }
func (w whereHelperbool) EQ(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.EQ, x) }
func (w whereHelperbool) NEQ(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.NEQ, x) }
func (w whereHelperbool) LT(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LT, x) }
func (w whereHelperbool) LTE(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LTE, x) }
func (w whereHelperbool) GT(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GT, x) }
func (w whereHelperbool) GTE(x bool) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GTE, x) }
var InviteWhere = struct {
ID whereHelperint64
HashedToken whereHelperstring