summaryrefslogtreecommitdiff
path: root/internal/federation
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-09-02 10:56:33 +0100
committerLibravatar GitHub <noreply@github.com>2022-09-02 11:56:33 +0200
commit614ab12733b991dbea9d1f7fa311a98072558727 (patch)
tree41780382cb71413566c8c87ce1ce0184c504253b /internal/federation
parent[feature] Emojify spoiler and content in web templates (#785) (diff)
downloadgotosocial-614ab12733b991dbea9d1f7fa311a98072558727.tar.xz
[performance] use GetAccountByUsernameDomain() for local account lookups to rely on cache (#793)
Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/federation')
-rw-r--r--internal/federation/dereferencing/account.go2
-rw-r--r--internal/federation/federatingdb/inbox.go2
-rw-r--r--internal/federation/federatingdb/owns.go10
-rw-r--r--internal/federation/federatingprotocol.go2
4 files changed, 8 insertions, 8 deletions
diff --git a/internal/federation/dereferencing/account.go b/internal/federation/dereferencing/account.go
index cbb9466ff..0fda96bf4 100644
--- a/internal/federation/dereferencing/account.go
+++ b/internal/federation/dereferencing/account.go
@@ -127,7 +127,7 @@ func (d *deref) GetRemoteAccount(ctx context.Context, params GetRemoteAccountPar
// to be a local account, so don't resolve
skipResolve = true
- if a, dbErr := d.db.GetLocalAccountByUsername(ctx, params.RemoteAccountUsername); dbErr == nil {
+ if a, dbErr := d.db.GetAccountByUsernameDomain(ctx, params.RemoteAccountUsername, ""); dbErr == nil {
foundAccount = a
} else if dbErr != db.ErrNoEntries {
err = fmt.Errorf("GetRemoteAccount: database error looking for local account with username %s: %s", params.RemoteAccountUsername, err)
diff --git a/internal/federation/federatingdb/inbox.go b/internal/federation/federatingdb/inbox.go
index 8d8ffffed..b3b935bff 100644
--- a/internal/federation/federatingdb/inbox.go
+++ b/internal/federation/federatingdb/inbox.go
@@ -85,7 +85,7 @@ func (f *federatingDB) InboxesForIRI(c context.Context, iri *url.URL) (inboxIRIs
return nil, fmt.Errorf("couldn't extract local account username from uri %s: %s", iri, err)
}
- account, err := f.db.GetLocalAccountByUsername(c, localAccountUsername)
+ account, err := f.db.GetAccountByUsernameDomain(c, localAccountUsername, "")
if err != nil {
return nil, fmt.Errorf("couldn't find local account with username %s: %s", localAccountUsername, err)
}
diff --git a/internal/federation/federatingdb/owns.go b/internal/federation/federatingdb/owns.go
index 6146f9c0a..c82dd847c 100644
--- a/internal/federation/federatingdb/owns.go
+++ b/internal/federation/federatingdb/owns.go
@@ -70,7 +70,7 @@ func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (bool, error) {
if err != nil {
return false, fmt.Errorf("error parsing statuses path for url %s: %s", id.String(), err)
}
- if _, err := f.db.GetLocalAccountByUsername(ctx, username); err != nil {
+ if _, err := f.db.GetAccountByUsernameDomain(ctx, username, ""); err != nil {
if err == db.ErrNoEntries {
// there are no entries for this username
return false, nil
@@ -87,7 +87,7 @@ func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (bool, error) {
if err != nil {
return false, fmt.Errorf("error parsing statuses path for url %s: %s", id.String(), err)
}
- if _, err := f.db.GetLocalAccountByUsername(ctx, username); err != nil {
+ if _, err := f.db.GetAccountByUsernameDomain(ctx, username, ""); err != nil {
if err == db.ErrNoEntries {
// there are no entries for this username
return false, nil
@@ -104,7 +104,7 @@ func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (bool, error) {
if err != nil {
return false, fmt.Errorf("error parsing statuses path for url %s: %s", id.String(), err)
}
- if _, err := f.db.GetLocalAccountByUsername(ctx, username); err != nil {
+ if _, err := f.db.GetAccountByUsernameDomain(ctx, username, ""); err != nil {
if err == db.ErrNoEntries {
// there are no entries for this username
return false, nil
@@ -121,7 +121,7 @@ func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (bool, error) {
if err != nil {
return false, fmt.Errorf("error parsing like path for url %s: %s", id.String(), err)
}
- if _, err := f.db.GetLocalAccountByUsername(ctx, username); err != nil {
+ if _, err := f.db.GetAccountByUsernameDomain(ctx, username, ""); err != nil {
if err == db.ErrNoEntries {
// there are no entries for this username
return false, nil
@@ -146,7 +146,7 @@ func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (bool, error) {
if err != nil {
return false, fmt.Errorf("error parsing block path for url %s: %s", id.String(), err)
}
- if _, err := f.db.GetLocalAccountByUsername(ctx, username); err != nil {
+ if _, err := f.db.GetAccountByUsernameDomain(ctx, username, ""); err != nil {
if err == db.ErrNoEntries {
// there are no entries for this username
return false, nil
diff --git a/internal/federation/federatingprotocol.go b/internal/federation/federatingprotocol.go
index 8242ca4b1..24dd471c2 100644
--- a/internal/federation/federatingprotocol.go
+++ b/internal/federation/federatingprotocol.go
@@ -157,7 +157,7 @@ func (f *federator) AuthenticatePostInbox(ctx context.Context, w http.ResponseWr
return nil, false, errors.New("username was empty")
}
- receivingAccount, err := f.db.GetLocalAccountByUsername(ctx, username)
+ receivingAccount, err := f.db.GetAccountByUsernameDomain(ctx, username, "")
if err != nil {
return nil, false, fmt.Errorf("could not fetch receiving account with username %s: %s", username, err)
}