diff options
Diffstat (limited to 'internal')
-rw-r--r-- | internal/config/config.go | 1 | ||||
-rw-r--r-- | internal/config/defaults.go | 1 | ||||
-rw-r--r-- | internal/config/flags.go | 1 | ||||
-rw-r--r-- | internal/config/helpers.gen.go | 26 | ||||
-rw-r--r-- | internal/web/base.go | 8 | ||||
-rw-r--r-- | internal/web/profile.go | 1 |
6 files changed, 37 insertions, 1 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index 79babf8bc..98114dea3 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -47,6 +47,7 @@ type Configuration struct { LogLevel string `name:"log-level" usage:"Log level to run at: [trace, debug, info, warn, fatal]"` LogDbQueries bool `name:"log-db-queries" usage:"Log database queries verbosely when log-level is trace or debug"` ApplicationName string `name:"application-name" usage:"Name of the application, used in various places internally"` + LandingPageUser string `name:"landing-page-user" usage:"the user that should be shown on the instance's landing page"` ConfigPath string `name:"config-path" usage:"Path to a file containing gotosocial configuration. Values set in this file will be overwritten by values set as env vars or arguments"` Host string `name:"host" usage:"Hostname to use for the server (eg., example.org, gotosocial.whatever.com). DO NOT change this on a server that's already run!"` AccountDomain string `name:"account-domain" usage:"Domain to use in account names (eg., example.org, whatever.com). If not set, will default to the setting for host. DO NOT change this on a server that's already run!"` diff --git a/internal/config/defaults.go b/internal/config/defaults.go index 7a2b806f8..37ca5e31d 100644 --- a/internal/config/defaults.go +++ b/internal/config/defaults.go @@ -26,6 +26,7 @@ var Defaults = Configuration{ LogLevel: "info", LogDbQueries: false, ApplicationName: "gotosocial", + LandingPageUser: "", ConfigPath: "", Host: "", AccountDomain: "", diff --git a/internal/config/flags.go b/internal/config/flags.go index 7b416815e..38d4cd51a 100644 --- a/internal/config/flags.go +++ b/internal/config/flags.go @@ -29,6 +29,7 @@ func AddGlobalFlags(cmd *cobra.Command) { Config(func(cfg *Configuration) { // General cmd.PersistentFlags().String(ApplicationNameFlag(), cfg.ApplicationName, fieldtag("ApplicationName", "usage")) + cmd.PersistentFlags().String(LandingPageUserFlag(), cfg.LandingPageUser, fieldtag("LandingPageUser", "usage")) cmd.PersistentFlags().String(HostFlag(), cfg.Host, fieldtag("Host", "usage")) cmd.PersistentFlags().String(AccountDomainFlag(), cfg.AccountDomain, fieldtag("AccountDomain", "usage")) cmd.PersistentFlags().String(ProtocolFlag(), cfg.Protocol, fieldtag("Protocol", "usage")) diff --git a/internal/config/helpers.gen.go b/internal/config/helpers.gen.go index 71f96920f..f42593a54 100644 --- a/internal/config/helpers.gen.go +++ b/internal/config/helpers.gen.go @@ -1794,3 +1794,29 @@ func GetAdvancedCookiesSamesite() string { return global.GetAdvancedCookiesSames // SetAdvancedCookiesSamesite safely sets the value for global configuration 'AdvancedCookiesSamesite' field func SetAdvancedCookiesSamesite(v string) { global.SetAdvancedCookiesSamesite(v) } + +// GetLandingPageUser safely fetches the Configuration value for state's 'LandingPageUser' field +func (st *ConfigState) GetLandingPageUser() (v string) { + st.mutex.Lock() + v = st.config.LandingPageUser + st.mutex.Unlock() + return +} + +// SetLandingPageUser safely sets the Configuration value for state's 'LandingPageUser' field +func (st *ConfigState) SetLandingPageUser(v string) { + st.mutex.Lock() + defer st.mutex.Unlock() + st.config.LandingPageUser = v + st.reloadToViper() +} + +// LandingPageUserFlag returns the flag name for the 'LandingPageUser' field +func LandingPageUserFlag() string { return "landing-page-user" } + +// GetLandingPageUser safely fetches the value for global configuration 'LandingPageUser' field +func GetLandingPageUser() string { return global.GetLandingPageUser() } + +// SetLandingPageUser safely sets the value for global configuration 'LandingPageUser' field +func SetLandingPageUser(v string) { global.SetLandingPageUser(v) } + diff --git a/internal/web/base.go b/internal/web/base.go index 61b4634ed..0dae30772 100644 --- a/internal/web/base.go +++ b/internal/web/base.go @@ -20,6 +20,7 @@ package web import ( "net/http" + "strings" "github.com/gin-gonic/gin" "github.com/superseriousbusiness/gotosocial/internal/api" @@ -28,6 +29,13 @@ import ( ) func (m *Module) baseHandler(c *gin.Context) { + + // if a landingPageUser is set in the config, redirect to that user's profile + if landingPageUser := config.GetLandingPageUser(); landingPageUser != "" { + c.Redirect(http.StatusFound, "/@"+c.Param(strings.ToLower(landingPageUser))) + return + } + host := config.GetHost() instance, err := m.processor.InstanceGet(c.Request.Context(), host) if err != nil { diff --git a/internal/web/profile.go b/internal/web/profile.go index 27de99e13..5023fa238 100644 --- a/internal/web/profile.go +++ b/internal/web/profile.go @@ -49,7 +49,6 @@ func (m *Module) profileGETHandler(c *gin.Context) { return } - // usernames on our instance will always be lowercase username := strings.ToLower(c.Param(usernameKey)) if username == "" { err := errors.New("no account username specified") |