[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>
This commit is contained in:
kim 2022-09-02 10:56:33 +01:00 committed by GitHub
commit 614ab12733
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 29 additions and 42 deletions

View file

@ -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