skip account on error instead of returning error (#251)

* skip account on error instead of returning error

* still return error on a real error
This commit is contained in:
tobi 2021-09-28 16:19:13 +02:00 committed by GitHub
parent b5a7e1ba32
commit 08cb8a3385
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View file

@ -54,7 +54,15 @@ func (f *federatingDB) Followers(ctx context.Context, actorIRI *url.URL) (follow
if follow.Account == nil {
followAccount, err := f.db.GetAccountByID(ctx, follow.AccountID)
if err != nil {
return nil, fmt.Errorf("FOLLOWERS: db error getting account id %s: %s", follow.AccountID, err)
errWrapped := fmt.Errorf("FOLLOWERS: db error getting account id %s: %s", follow.AccountID, err)
if err == db.ErrNoEntries {
// no entry for this account id so it's probably been deleted and we haven't caught up yet
l.Error(errWrapped)
continue
} else {
// proper error
return nil, errWrapped
}
}
follow.Account = followAccount
}

View file

@ -8,6 +8,7 @@
"github.com/go-fed/activity/streams"
"github.com/go-fed/activity/streams/vocab"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/util"
)
@ -67,7 +68,15 @@ func (f *federatingDB) Following(ctx context.Context, actorIRI *url.URL) (follow
if follow.Account == nil {
followAccount, err := f.db.GetAccountByID(ctx, follow.AccountID)
if err != nil {
return nil, fmt.Errorf("FOLLOWING: db error getting account id %s: %s", follow.AccountID, err)
errWrapped := fmt.Errorf("FOLLOWING: db error getting account id %s: %s", follow.AccountID, err)
if err == db.ErrNoEntries {
// no entry for this account id so it's probably been deleted and we haven't caught up yet
l.Error(errWrapped)
continue
} else {
// proper error
return nil, errWrapped
}
}
follow.Account = followAccount
}