From d0dee8d0b6c795e4691a48d0d2e089721dcf7c72 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Wed, 8 Mar 2023 17:19:49 +0000 Subject: [PATCH] [chore] improved enrichAccount() logging (#1602) * slight refactor and improved logging on failed webfinger in enrichAccount() * use correct log format directive --------- Signed-off-by: kim --- internal/federation/dereferencing/account.go | 18 ++++++++++++------ 1 file 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 }