diff options
author | 2021-08-20 12:26:56 +0200 | |
---|---|---|
committer | 2021-08-20 12:26:56 +0200 | |
commit | 4920229a3b6e1d7dde536bc9ff766542b05d935c (patch) | |
tree | a9423beccec5331c372f01eedf38949dfb171e9e /internal/federation/federatingdb/following.go | |
parent | Text/status parsing fixes (#141) (diff) | |
download | gotosocial-4920229a3b6e1d7dde536bc9ff766542b05d935c.tar.xz |
Database updates (#144)
* start moving some database stuff around
* continue moving db stuff around
* more fiddling
* more updates
* and some more
* and yet more
* i broke SOMETHING but what, it's a mystery
* tidy up
* vendor ttlcache
* use ttlcache
* fix up some tests
* rename some stuff
* little reminder
* some more updates
Diffstat (limited to 'internal/federation/federatingdb/following.go')
-rw-r--r-- | internal/federation/federatingdb/following.go | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/internal/federation/federatingdb/following.go b/internal/federation/federatingdb/following.go index f92041e1e..45785c671 100644 --- a/internal/federation/federatingdb/following.go +++ b/internal/federation/federatingdb/following.go @@ -8,7 +8,6 @@ import ( "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" ) @@ -28,21 +27,37 @@ func (f *federatingDB) Following(c context.Context, actorIRI *url.URL) (followin ) l.Debugf("entering FOLLOWING function with actorIRI %s", actorIRI.String()) - acct := >smodel.Account{} + var acct *gtsmodel.Account if util.IsUserPath(actorIRI) { - if err := f.db.GetWhere([]db.Where{{Key: "uri", Value: actorIRI.String()}}, acct); err != nil { + username, err := util.ParseUserPath(actorIRI) + if err != nil { + return nil, fmt.Errorf("FOLLOWING: error parsing user path: %s", err) + } + + a, err := f.db.GetLocalAccountByUsername(username) + if err != nil { return nil, fmt.Errorf("FOLLOWING: db error getting account with uri %s: %s", actorIRI.String(), err) } + + acct = a } else if util.IsFollowingPath(actorIRI) { - if err := f.db.GetWhere([]db.Where{{Key: "following_uri", Value: actorIRI.String()}}, acct); err != nil { + username, err := util.ParseFollowingPath(actorIRI) + if err != nil { + return nil, fmt.Errorf("FOLLOWING: error parsing following path: %s", err) + } + + a, err := f.db.GetLocalAccountByUsername(username) + if err != nil { return nil, fmt.Errorf("FOLLOWING: db error getting account with following uri %s: %s", actorIRI.String(), err) } + + acct = a } else { return nil, fmt.Errorf("FOLLOWING: could not parse actor IRI %s as users or following path", actorIRI.String()) } - acctFollowing := []gtsmodel.Follow{} - if err := f.db.GetFollowingByAccountID(acct.ID, &acctFollowing); err != nil { + acctFollowing, err := f.db.GetAccountFollows(acct.ID) + if err != nil { return nil, fmt.Errorf("FOLLOWING: db error getting following for account id %s: %s", acct.ID, err) } |