summaryrefslogtreecommitdiff
path: root/internal/processing/account/createfollow.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/createfollow.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/createfollow.go')
-rw-r--r--internal/processing/account/createfollow.go29
1 files changed, 12 insertions, 17 deletions
diff --git a/internal/processing/account/createfollow.go b/internal/processing/account/createfollow.go
index e89db9d47..8c856a50e 100644
--- a/internal/processing/account/createfollow.go
+++ b/internal/processing/account/createfollow.go
@@ -31,38 +31,33 @@ import (
func (p *processor) FollowCreate(requestingAccount *gtsmodel.Account, form *apimodel.AccountFollowRequest) (*apimodel.Relationship, gtserror.WithCode) {
// if there's a block between the accounts we shouldn't create the request ofc
- blocked, err := p.db.Blocked(requestingAccount.ID, form.ID)
- if err != nil {
+ if blocked, err := p.db.IsBlocked(requestingAccount.ID, form.ID, true); err != nil {
return nil, gtserror.NewErrorInternalError(err)
- }
- if blocked {
- return nil, gtserror.NewErrorNotFound(fmt.Errorf("accountfollowcreate: block exists between accounts"))
+ } else if blocked {
+ return nil, gtserror.NewErrorNotFound(fmt.Errorf("block exists between accounts"))
}
// make sure the target account actually exists in our db
- targetAcct := &gtsmodel.Account{}
- if err := p.db.GetByID(form.ID, targetAcct); err != nil {
- if _, ok := err.(db.ErrNoEntries); ok {
+ targetAcct, err := p.db.GetAccountByID(form.ID)
+ if err != nil {
+ if err == db.ErrNoEntries {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("accountfollowcreate: account %s not found in the db: %s", form.ID, err))
}
+ return nil, gtserror.NewErrorInternalError(err)
}
// check if a follow exists already
- follows, err := p.db.Follows(requestingAccount, targetAcct)
- if err != nil {
+ if follows, err := p.db.IsFollowing(requestingAccount, targetAcct); err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("accountfollowcreate: error checking follow in db: %s", err))
- }
- if follows {
+ } else if follows {
// already follows so just return the relationship
return p.RelationshipGet(requestingAccount, form.ID)
}
- // check if a follow exists already
- followRequested, err := p.db.FollowRequested(requestingAccount, targetAcct)
- if err != nil {
+ // check if a follow request exists already
+ if followRequested, err := p.db.IsFollowRequested(requestingAccount, targetAcct); err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("accountfollowcreate: error checking follow request in db: %s", err))
- }
- if followRequested {
+ } else if followRequested {
// already follow requested so just return the relationship
return p.RelationshipGet(requestingAccount, form.ID)
}