diff --git a/cmd/bbctl/main.go b/cmd/bbctl/main.go index 429c209..cdb31a7 100644 --- a/cmd/bbctl/main.go +++ b/cmd/bbctl/main.go @@ -81,14 +81,14 @@ func prepareApp(ctx *cli.Context) error { envConfig := cfg.Environments.Get(env) ctx.Context = context.WithValue(ctx.Context, contextKeyConfig, cfg) ctx.Context = context.WithValue(ctx.Context, contextKeyEnvConfig, envConfig) - if envConfig.HungryAddress == "" { - whoami, err := beeperapi.Whoami(homeserver, envConfig.AccessToken) - if err != nil { - return fmt.Errorf("failed to get whoami: %w", err) - } - SaveHungryURL(ctx, whoami.UserInfo.HungryURL) - } if envConfig.HasCredentials() { + if envConfig.HungryAddress == "" { + whoami, err := beeperapi.Whoami(homeserver, envConfig.AccessToken) + if err != nil { + return fmt.Errorf("failed to get whoami: %w", err) + } + SaveHungryURL(ctx, whoami.UserInfo.HungryURL) + } homeserver := ctx.String("homeserver") ctx.Context = context.WithValue(ctx.Context, contextKeyMatrixClient, NewMatrixAPI(homeserver, envConfig.Username, envConfig.AccessToken)) ctx.Context = context.WithValue(ctx.Context, contextKeyHungryClient, hungryapi.NewClient(homeserver, envConfig.HungryAddress, envConfig.Username, envConfig.AccessToken))