summaryrefslogtreecommitdiff
path: root/internal/federation/dereferencing/account.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-03-03 08:34:34 +0000
committerLibravatar GitHub <noreply@github.com>2023-03-03 09:34:34 +0100
commitfe6c8b8152d723ff3788e35c79b2e840926d5b22 (patch)
treeb171b65fa54b8f5111561cb651670ae8bebfb613 /internal/federation/dereferencing/account.go
parent[bugfix] add ON CONFLICT statements to status updates (#1580) (diff)
downloadgotosocial-fe6c8b8152d723ff3788e35c79b2e840926d5b22.tar.xz
[bugfix] on deref new account, check db again for account on ErrAlreadyExists (#1581)
Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/federation/dereferencing/account.go')
-rw-r--r--internal/federation/dereferencing/account.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/federation/dereferencing/account.go b/internal/federation/dereferencing/account.go
index 041f34a2c..6502c0e96 100644
--- a/internal/federation/dereferencing/account.go
+++ b/internal/federation/dereferencing/account.go
@@ -293,8 +293,15 @@ func (d *deref) enrichAccount(ctx context.Context, requestUser string, uri *url.
latestAcc.CreatedAt = latestAcc.FetchedAt
latestAcc.UpdatedAt = latestAcc.FetchedAt
- // This is a new account, we need to place it in the database.
- if err := d.db.PutAccount(ctx, latestAcc); err != nil {
+ // This is new, put it in the database.
+ err := d.db.PutAccount(ctx, latestAcc)
+
+ if errors.Is(err, db.ErrAlreadyExists) {
+ // TODO: replace this quick fix with per-URI deref locks.
+ latestAcc, err = d.db.GetAccountByURI(ctx, latestAcc.URI)
+ }
+
+ if err != nil {
return nil, fmt.Errorf("enrichAccount: error putting in database: %w", err)
}
} else {