diff options
author | 2023-03-08 17:19:49 +0000 | |
---|---|---|
committer | 2023-03-08 17:19:49 +0000 | |
commit | d0dee8d0b6c795e4691a48d0d2e089721dcf7c72 (patch) | |
tree | 32be71927968868cf31f3295b743db37b69436fa | |
parent | [feature] Discover webfinger through host-meta (#1588) (diff) | |
download | gotosocial-d0dee8d0b6c795e4691a48d0d2e089721dcf7c72.tar.xz |
[chore] improved enrichAccount() logging (#1602)
* slight refactor and improved logging on failed webfinger in enrichAccount()
* use correct log format directive
---------
Signed-off-by: kim <grufwub@gmail.com>
-rw-r--r-- | internal/federation/dereferencing/account.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/internal/federation/dereferencing/account.go b/internal/federation/dereferencing/account.go index 6502c0e96..5d7094a80 100644 --- a/internal/federation/dereferencing/account.go +++ b/internal/federation/dereferencing/account.go @@ -156,13 +156,15 @@ func (d *deref) enrichAccount(ctx context.Context, requestUser string, uri *url. // A username was provided so we can attempt a webfinger, this ensures up-to-date accountdomain info. accDomain, accURI, err := d.fingerRemoteAccount(ctx, transport, account.Username, account.Domain) - if err != nil && account.URI == "" { - // this is a new account (to us) with username@domain but failed - // webfinger, there is nothing more we can do in this situation. + switch { + case err != nil && account.URI == "": + // this is a new account (to us) with username@domain but failed webfinger, nothing more we can do. return nil, fmt.Errorf("enrichAccount: error webfingering account: %w", err) - } - if err == nil { + case err != nil: + log.Errorf(ctx, "error webfingering[1] remote account %s@%s: %v", account.Username, account.Domain, err) + + case err == nil: if account.Domain != accDomain { // After webfinger, we now have correct account domain from which we can do a final DB check. alreadyAccount, err := d.db.GetAccountByUsernameDomain(ctx, account.Username, accDomain) @@ -224,7 +226,11 @@ func (d *deref) enrichAccount(ctx context.Context, requestUser string, uri *url. // Now we have a username we can attempt it, this ensures up-to-date accountdomain info. accDomain, _, err := d.fingerRemoteAccount(ctx, transport, latestAcc.Username, uri.Host) - if err == nil { + switch { + case err != nil: + log.Errorf(ctx, "error webfingering[2] remote account %s@%s: %v", latestAcc.Username, uri.Host, err) + + case err == nil: // Update account with latest info. latestAcc.Domain = accDomain } |