summaryrefslogtreecommitdiff
path: root/internal/federation/federatingdb/following.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/federation/federatingdb/following.go')
-rw-r--r--internal/federation/federatingdb/following.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/internal/federation/federatingdb/following.go b/internal/federation/federatingdb/following.go
index 45785c671..9d5c0693c 100644
--- a/internal/federation/federatingdb/following.go
+++ b/internal/federation/federatingdb/following.go
@@ -18,7 +18,7 @@ import (
// If modified, the library will then call Update.
//
// The library makes this call only after acquiring a lock first.
-func (f *federatingDB) Following(c context.Context, actorIRI *url.URL) (following vocab.ActivityStreamsCollection, err error) {
+func (f *federatingDB) Following(ctx context.Context, actorIRI *url.URL) (following vocab.ActivityStreamsCollection, err error) {
l := f.log.WithFields(
logrus.Fields{
"func": "Following",
@@ -34,7 +34,7 @@ func (f *federatingDB) Following(c context.Context, actorIRI *url.URL) (followin
return nil, fmt.Errorf("FOLLOWING: error parsing user path: %s", err)
}
- a, err := f.db.GetLocalAccountByUsername(username)
+ a, err := f.db.GetLocalAccountByUsername(ctx, username)
if err != nil {
return nil, fmt.Errorf("FOLLOWING: db error getting account with uri %s: %s", actorIRI.String(), err)
}
@@ -46,7 +46,7 @@ func (f *federatingDB) Following(c context.Context, actorIRI *url.URL) (followin
return nil, fmt.Errorf("FOLLOWING: error parsing following path: %s", err)
}
- a, err := f.db.GetLocalAccountByUsername(username)
+ a, err := f.db.GetLocalAccountByUsername(ctx, username)
if err != nil {
return nil, fmt.Errorf("FOLLOWING: db error getting account with following uri %s: %s", actorIRI.String(), err)
}
@@ -56,7 +56,7 @@ func (f *federatingDB) Following(c context.Context, actorIRI *url.URL) (followin
return nil, fmt.Errorf("FOLLOWING: could not parse actor IRI %s as users or following path", actorIRI.String())
}
- acctFollowing, err := f.db.GetAccountFollows(acct.ID)
+ acctFollowing, err := f.db.GetAccountFollows(ctx, acct.ID)
if err != nil {
return nil, fmt.Errorf("FOLLOWING: db error getting following for account id %s: %s", acct.ID, err)
}
@@ -64,13 +64,17 @@ func (f *federatingDB) Following(c context.Context, actorIRI *url.URL) (followin
following = streams.NewActivityStreamsCollection()
items := streams.NewActivityStreamsItemsProperty()
for _, follow := range acctFollowing {
- gtsFollowing := &gtsmodel.Account{}
- if err := f.db.GetByID(follow.AccountID, gtsFollowing); err != nil {
- return nil, fmt.Errorf("FOLLOWING: db error getting account id %s: %s", follow.AccountID, err)
+ 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)
+ }
+ follow.Account = followAccount
}
- uri, err := url.Parse(gtsFollowing.URI)
+
+ uri, err := url.Parse(follow.Account.URI)
if err != nil {
- return nil, fmt.Errorf("FOLLOWING: error parsing %s as url: %s", gtsFollowing.URI, err)
+ return nil, fmt.Errorf("FOLLOWING: error parsing %s as url: %s", follow.Account.URI, err)
}
items.AppendIRI(uri)
}