From f7c0e823e2d809e36c078bdb455c8e6e81c9e78f Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 22 Jun 2023 23:47:35 +0300 Subject: [PATCH] Move hungry address filling to correct place. Fixes #2 --- cmd/bbctl/main.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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))