6
1
mirror of https://git.mills.io/saltyim/saltyim.git synced 2024-06-30 02:31:08 +00:00

fix: Make register lookup broker if default to blank (#175)

Co-authored-by: Jon Lundy <jon@xuu.cc>
Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/175
Reviewed-by: James Mills <james@mills.io>
Co-authored-by: xuu <xuu@noreply@mills.io>
Co-committed-by: xuu <xuu@noreply@mills.io>
This commit is contained in:
xuu 2022-10-15 21:45:13 +00:00 committed by James Mills
parent 37135ce6af
commit 318c3275b5
6 changed files with 9 additions and 1 deletions

1
.gitignore vendored

@ -26,3 +26,4 @@
/echobot.sh /echobot.sh
/execbot.sh /execbot.sh
environ.inc

@ -17,7 +17,9 @@ type Config struct {
Data string `json:"-"` Data string `json:"-"`
Store string `json:"-"` Store string `json:"-"`
BaseURL string BaseURL string
BrokerURI string
PrimaryDomain string PrimaryDomain string
AdminUser string `json:"-"` AdminUser string `json:"-"`

@ -120,6 +120,10 @@ func WithBaseURL(baseURL string) Option {
return err return err
} }
cfg.BaseURL = baseURL cfg.BaseURL = baseURL
if baseURL != DefaultBaseURL {
cfg.BrokerURI = baseURL
}
cfg.baseURL = u cfg.baseURL = u
return nil return nil
} }

@ -121,7 +121,7 @@ func (c *Configuration) registerIdentity() func(button app.HTMLButton) {
log.Println("error", err) log.Println("error", err)
return return
} }
err = registerClient.Register(app.Getenv("BaseURL")) err = registerClient.Register(app.Getenv("BrokerURI"))
if err != nil { // TODO: pop dialog if err != nil { // TODO: pop dialog
log.Println("error", err) log.Println("error", err)
c.dialog.ShowError("error registering to broker: ", err.Error()) c.dialog.ShowError("error registering to broker: ", err.Error())

@ -289,6 +289,7 @@ func (s *Server) initRoutes() {
Env: map[string]string{ Env: map[string]string{
"BaseURL": strings.TrimSuffix(s.config.BaseURL, "/"), "BaseURL": strings.TrimSuffix(s.config.BaseURL, "/"),
"BrokerURI": strings.TrimSuffix(s.config.BrokerURI, "/"),
"LookupEndpoint": strings.TrimSuffix(s.config.BaseURL, "/") + "/api/v1/lookup/", "LookupEndpoint": strings.TrimSuffix(s.config.BaseURL, "/") + "/api/v1/lookup/",
"SendEndpoint": strings.TrimSuffix(s.config.BaseURL, "/") + "/api/v1/send", "SendEndpoint": strings.TrimSuffix(s.config.BaseURL, "/") + "/api/v1/send",
}, },

Binary file not shown.