diff options
Diffstat (limited to 'internal/federation')
-rw-r--r-- | internal/federation/federatingdb/followers.go | 14 | ||||
-rw-r--r-- | internal/federation/federatingdb/following.go | 16 |
2 files changed, 9 insertions, 21 deletions
diff --git a/internal/federation/federatingdb/followers.go b/internal/federation/federatingdb/followers.go index eada48c1b..88cf02d6b 100644 --- a/internal/federation/federatingdb/followers.go +++ b/internal/federation/federatingdb/followers.go @@ -23,7 +23,7 @@ import ( "net/url" "github.com/superseriousbusiness/activity/streams/vocab" - "github.com/superseriousbusiness/gotosocial/internal/log" + "github.com/superseriousbusiness/gotosocial/internal/gtserror" ) // Followers obtains the Followers Collection for an actor with the @@ -38,25 +38,19 @@ func (f *federatingDB) Followers(ctx context.Context, actorIRI *url.URL) (follow return nil, err } + // Fetch followers for account from database. follows, err := f.state.DB.GetAccountFollowers(ctx, acct.ID, nil) if err != nil { return nil, fmt.Errorf("Followers: db error getting followers for account id %s: %s", acct.ID, err) } + // Convert the followers to a slice of account URIs. iris := make([]*url.URL, 0, len(follows)) for _, follow := range follows { - if follow.Account == nil { - // Follow account no longer exists, - // for some reason. Skip this one. - log.WithContext(ctx).WithField("follow", follow).Warnf("follow missing account %s", follow.AccountID) - continue - } - u, err := url.Parse(follow.Account.URI) if err != nil { - return nil, err + return nil, gtserror.Newf("invalid account uri: %v", err) } - iris = append(iris, u) } diff --git a/internal/federation/federatingdb/following.go b/internal/federation/federatingdb/following.go index deb965564..c30c13317 100644 --- a/internal/federation/federatingdb/following.go +++ b/internal/federation/federatingdb/following.go @@ -19,11 +19,10 @@ package federatingdb import ( "context" - "fmt" "net/url" "github.com/superseriousbusiness/activity/streams/vocab" - "github.com/superseriousbusiness/gotosocial/internal/log" + "github.com/superseriousbusiness/gotosocial/internal/gtserror" ) // Following obtains the Following Collection for an actor with the @@ -38,23 +37,18 @@ func (f *federatingDB) Following(ctx context.Context, actorIRI *url.URL) (follow return nil, err } + // Fetch follows for account from database. follows, err := f.state.DB.GetAccountFollows(ctx, acct.ID, nil) if err != nil { - return nil, fmt.Errorf("Following: db error getting following for account id %s: %w", acct.ID, err) + return nil, gtserror.Newf("db error getting following for account id %s: %w", acct.ID, err) } + // Convert the follows to a slice of account URIs. iris := make([]*url.URL, 0, len(follows)) for _, follow := range follows { - if follow.TargetAccount == nil { - // Follow target account no longer exists, - // for some reason. Skip this one. - log.WithContext(ctx).WithField("follow", follow).Warnf("follow missing target account %s", follow.TargetAccountID) - continue - } - u, err := url.Parse(follow.TargetAccount.URI) if err != nil { - return nil, err + return nil, gtserror.Newf("invalid account uri: %v", err) } iris = append(iris, u) } |