summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-02-09 10:34:44 +0100
committerLibravatar GitHub <noreply@github.com>2023-02-09 10:34:44 +0100
commite5e257c2597dec1997b101fb5555a7e83972985f (patch)
tree1d0742c89fa56e0c6d6ce66740217712afef4cd8
parent[performance] Don't fetch avatar + header if uri hasn't changed (#1463) (diff)
downloadgotosocial-e5e257c2597dec1997b101fb5555a7e83972985f.tar.xz
[bugfix] Fix error on searching for account w/accountDomain by host (#1465)
-rw-r--r--internal/federation/dereferencing/account.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/federation/dereferencing/account.go b/internal/federation/dereferencing/account.go
index ceb7820dc..14864c1b5 100644
--- a/internal/federation/dereferencing/account.go
+++ b/internal/federation/dereferencing/account.go
@@ -162,6 +162,24 @@ func (d *deref) enrichAccount(ctx context.Context, requestUser string, uri *url.
}
if err == nil {
+ if account.Domain != accDomain {
+ // We have the correct accountDomain now; if it was different from
+ // the account domain we were provided, do another db lookup to check
+ // if we already had the account in the db under the account domain we
+ // just discovered, otherwise we risk thinking this is a new account
+ // and trying to put it into the database again (which will cause issues).
+ alreadyAccount, err := d.db.GetAccountByUsernameDomain(ctx, account.Username, accDomain)
+ if err != nil && !errors.Is(err, db.ErrNoEntries) {
+ return nil, fmt.Errorf("enrichAccount: db err looking for account again after webfinger: %w", err)
+ }
+
+ if err == nil {
+ // We already had the account in the database;
+ // continue by enriching that one instead.
+ account = alreadyAccount
+ }
+ }
+
// Update account with latest info.
account.URI = accURI.String()
account.Domain = accDomain