summaryrefslogtreecommitdiff
path: root/internal/processing/account/getfollowing.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-08-20 12:26:56 +0200
committerLibravatar GitHub <noreply@github.com>2021-08-20 12:26:56 +0200
commit4920229a3b6e1d7dde536bc9ff766542b05d935c (patch)
treea9423beccec5331c372f01eedf38949dfb171e9e /internal/processing/account/getfollowing.go
parentText/status parsing fixes (#141) (diff)
downloadgotosocial-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/processing/account/getfollowing.go')
-rw-r--r--internal/processing/account/getfollowing.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/internal/processing/account/getfollowing.go b/internal/processing/account/getfollowing.go
index 75e89dacb..c7fb426f9 100644
--- a/internal/processing/account/getfollowing.go
+++ b/internal/processing/account/getfollowing.go
@@ -28,26 +28,23 @@ import (
)
func (p *processor) FollowingGet(requestingAccount *gtsmodel.Account, targetAccountID string) ([]apimodel.Account, gtserror.WithCode) {
- blocked, err := p.db.Blocked(requestingAccount.ID, targetAccountID)
- if err != nil {
+ if blocked, err := p.db.IsBlocked(requestingAccount.ID, targetAccountID, true); err != nil {
return nil, gtserror.NewErrorInternalError(err)
- }
-
- if blocked {
+ } else if blocked {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("block exists between accounts"))
}
- following := []gtsmodel.Follow{}
accounts := []apimodel.Account{}
- if err := p.db.GetFollowingByAccountID(targetAccountID, &following); err != nil {
- if _, ok := err.(db.ErrNoEntries); ok {
+ follows, err := p.db.GetAccountFollows(targetAccountID)
+ if err != nil {
+ if err == db.ErrNoEntries {
return accounts, nil
}
return nil, gtserror.NewErrorInternalError(err)
}
- for _, f := range following {
- blocked, err := p.db.Blocked(requestingAccount.ID, f.AccountID)
+ for _, f := range follows {
+ blocked, err := p.db.IsBlocked(requestingAccount.ID, f.AccountID, true)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@@ -55,15 +52,18 @@ func (p *processor) FollowingGet(requestingAccount *gtsmodel.Account, targetAcco
continue
}
- a := &gtsmodel.Account{}
- if err := p.db.GetByID(f.TargetAccountID, a); err != nil {
- if _, ok := err.(db.ErrNoEntries); ok {
- continue
+ if f.TargetAccount == nil {
+ a, err := p.db.GetAccountByID(f.TargetAccountID)
+ if err != nil {
+ if err == db.ErrNoEntries {
+ continue
+ }
+ return nil, gtserror.NewErrorInternalError(err)
}
- return nil, gtserror.NewErrorInternalError(err)
+ f.TargetAccount = a
}
- account, err := p.tc.AccountToMastoPublic(a)
+ account, err := p.tc.AccountToMastoPublic(f.TargetAccount)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}