Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] Fix error on searching for account w/accountDomain by host #1465

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions internal/federation/dereferencing/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down