rename some stuff

This commit is contained in:
tsmethurst 2021-08-19 22:05:24 +02:00
commit 32ed58a100
33 changed files with 203 additions and 114 deletions

View file

@ -37,7 +37,7 @@ func (p *processor) BlockCreate(requestingAccount *gtsmodel.Account, targetAccou
}
// if requestingAccount already blocks target account, we don't need to do anything
if blocked, err := p.db.Blocked(requestingAccount.ID, targetAccountID, false); err != nil {
if blocked, err := p.db.IsBlocked(requestingAccount.ID, targetAccountID, false); err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("BlockCreate: error checking existence of block: %s", err))
} else if blocked {
return p.RelationshipGet(requestingAccount, targetAccountID)

View file

@ -31,7 +31,7 @@ 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
if blocked, err := p.db.Blocked(requestingAccount.ID, form.ID, true); err != nil {
if blocked, err := p.db.IsBlocked(requestingAccount.ID, form.ID, true); err != nil {
return nil, gtserror.NewErrorInternalError(err)
} else if blocked {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("block exists between accounts"))
@ -47,7 +47,7 @@ func (p *processor) FollowCreate(requestingAccount *gtsmodel.Account, form *apim
}
// check if a follow exists already
if follows, err := p.db.Follows(requestingAccount, targetAcct); 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))
} else if follows {
// already follows so just return the relationship
@ -55,7 +55,7 @@ func (p *processor) FollowCreate(requestingAccount *gtsmodel.Account, form *apim
}
// check if a follow request exists already
if followRequested, err := p.db.FollowRequested(requestingAccount, targetAcct); err != nil {
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))
} else if followRequested {
// already follow requested so just return the relationship

View file

@ -39,7 +39,7 @@ func (p *processor) Get(requestingAccount *gtsmodel.Account, targetAccountID str
var blocked bool
var err error
if requestingAccount != nil {
blocked, err = p.db.Blocked(requestingAccount.ID, targetAccountID, true)
blocked, err = p.db.IsBlocked(requestingAccount.ID, targetAccountID, true)
if err != nil {
return nil, fmt.Errorf("error checking account block: %s", err)
}

View file

@ -28,7 +28,7 @@ import (
)
func (p *processor) FollowersGet(requestingAccount *gtsmodel.Account, targetAccountID string) ([]apimodel.Account, gtserror.WithCode) {
if blocked, err := p.db.Blocked(requestingAccount.ID, targetAccountID, true); err != nil {
if blocked, err := p.db.IsBlocked(requestingAccount.ID, targetAccountID, true); err != nil {
return nil, gtserror.NewErrorInternalError(err)
} else if blocked {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("block exists between accounts"))
@ -44,7 +44,7 @@ func (p *processor) FollowersGet(requestingAccount *gtsmodel.Account, targetAcco
}
for _, f := range followers {
blocked, err := p.db.Blocked(requestingAccount.ID, f.AccountID, true)
blocked, err := p.db.IsBlocked(requestingAccount.ID, f.AccountID, true)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}

View file

@ -28,7 +28,7 @@ import (
)
func (p *processor) FollowingGet(requestingAccount *gtsmodel.Account, targetAccountID string) ([]apimodel.Account, gtserror.WithCode) {
if blocked, err := p.db.Blocked(requestingAccount.ID, targetAccountID, true); err != nil {
if blocked, err := p.db.IsBlocked(requestingAccount.ID, targetAccountID, true); err != nil {
return nil, gtserror.NewErrorInternalError(err)
} else if blocked {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("block exists between accounts"))
@ -36,7 +36,7 @@ func (p *processor) FollowingGet(requestingAccount *gtsmodel.Account, targetAcco
following := []gtsmodel.Follow{}
accounts := []apimodel.Account{}
if err := p.db.GetAccountFollowing(targetAccountID, &following); err != nil {
if err := p.db.GetAccountFollows(targetAccountID, &following); err != nil {
if err == db.ErrNoEntries {
return accounts, nil
}
@ -44,7 +44,7 @@ func (p *processor) FollowingGet(requestingAccount *gtsmodel.Account, targetAcco
}
for _, f := range following {
blocked, err := p.db.Blocked(requestingAccount.ID, f.AccountID, true)
blocked, err := p.db.IsBlocked(requestingAccount.ID, f.AccountID, true)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}

View file

@ -28,7 +28,7 @@ import (
)
func (p *processor) StatusesGet(requestingAccount *gtsmodel.Account, targetAccountID string, limit int, excludeReplies bool, maxID string, pinnedOnly bool, mediaOnly bool) ([]apimodel.Status, gtserror.WithCode) {
if blocked, err := p.db.Blocked(requestingAccount.ID, targetAccountID, true); err != nil {
if blocked, err := p.db.IsBlocked(requestingAccount.ID, targetAccountID, true); err != nil {
return nil, gtserror.NewErrorInternalError(err)
} else if blocked {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("block exists between accounts"))

View file

@ -29,7 +29,7 @@ import (
func (p *processor) FollowRemove(requestingAccount *gtsmodel.Account, targetAccountID string) (*apimodel.Relationship, gtserror.WithCode) {
// if there's a block between the accounts we shouldn't do anything
blocked, err := p.db.Blocked(requestingAccount.ID, targetAccountID, true)
blocked, err := p.db.IsBlocked(requestingAccount.ID, targetAccountID, true)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}