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)
}

View file

@ -123,7 +123,7 @@ func (p *processor) initiateDomainBlockSideEffects(account *gtsmodel.Account, bl
selectAccountsLoop:
for {
accounts, err := p.db.GetAccountsForInstance(block.Domain, maxID, limit)
accounts, err := p.db.GetInstanceAccounts(block.Domain, maxID, limit)
if err != nil {
if err == db.ErrNoEntries {
// no accounts left for this instance so we're done

View file

@ -62,7 +62,7 @@ func (p *processor) GetFediUser(ctx context.Context, requestedUsername string, r
return nil, gtserror.NewErrorNotAuthorized(err)
}
blocked, err := p.db.Blocked(requestedAccount.ID, requestingAccount.ID, true)
blocked, err := p.db.IsBlocked(requestedAccount.ID, requestingAccount.ID, true)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@ -106,7 +106,7 @@ func (p *processor) GetFediFollowers(ctx context.Context, requestedUsername stri
return nil, gtserror.NewErrorNotAuthorized(err)
}
blocked, err := p.db.Blocked(requestedAccount.ID, requestingAccount.ID, true)
blocked, err := p.db.IsBlocked(requestedAccount.ID, requestingAccount.ID, true)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@ -151,7 +151,7 @@ func (p *processor) GetFediFollowing(ctx context.Context, requestedUsername stri
return nil, gtserror.NewErrorNotAuthorized(err)
}
blocked, err := p.db.Blocked(requestedAccount.ID, requestingAccount.ID, true)
blocked, err := p.db.IsBlocked(requestedAccount.ID, requestingAccount.ID, true)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@ -198,7 +198,7 @@ func (p *processor) GetFediStatus(ctx context.Context, requestedUsername string,
// authorize the request:
// 1. check if a block exists between the requester and the requestee
blocked, err := p.db.Blocked(requestedAccount.ID, requestingAccount.ID, true)
blocked, err := p.db.IsBlocked(requestedAccount.ID, requestingAccount.ID, true)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@ -258,7 +258,7 @@ func (p *processor) GetFediStatusReplies(ctx context.Context, requestedUsername
// authorize the request:
// 1. check if a block exists between the requester and the requestee
blocked, err := p.db.Blocked(requestedAccount.ID, requestingAccount.ID, true)
blocked, err := p.db.IsBlocked(requestedAccount.ID, requestingAccount.ID, true)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}

View file

@ -27,8 +27,8 @@ import (
)
func (p *processor) FollowRequestsGet(auth *oauth.Auth) ([]apimodel.Account, gtserror.WithCode) {
frs := []gtsmodel.FollowRequest{}
if err := p.db.GetAccountFollowRequests(auth.Account.ID, &frs); err != nil {
frs, err := p.db.GetAccountFollowRequests(auth.Account.ID)
if err != nil {
if err != db.ErrNoEntries {
return nil, gtserror.NewErrorInternalError(err)
}

View file

@ -57,7 +57,7 @@ func (p *processor) GetFile(account *gtsmodel.Account, form *apimodel.GetContent
// make sure the requesting account and the media account don't block each other
if account != nil {
blocked, err := p.db.Blocked(account.ID, form.AccountID, true)
blocked, err := p.db.IsBlocked(account.ID, form.AccountID, true)
if err != nil {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("block status could not be established between accounts %s and %s: %s", form.AccountID, account.ID, err))
}

View file

@ -27,7 +27,7 @@ import (
func (p *processor) NotificationsGet(authed *oauth.Auth, limit int, maxID string, sinceID string) ([]*apimodel.Notification, gtserror.WithCode) {
l := p.log.WithField("func", "NotificationsGet")
notifs, err := p.db.GetNotificationsForAccount(authed.Account.ID, limit, maxID, sinceID)
notifs, err := p.db.GetNotifications(authed.Account.ID, limit, maxID, sinceID)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}

View file

@ -90,7 +90,7 @@ func (p *processor) SearchGet(authed *oauth.Auth, searchQuery *apimodel.SearchQu
*/
for _, foundAccount := range foundAccounts {
// make sure there's no block in either direction between the account and the requester
if blocked, err := p.db.Blocked(authed.Account.ID, foundAccount.ID, true); err == nil && !blocked {
if blocked, err := p.db.IsBlocked(authed.Account.ID, foundAccount.ID, true); err == nil && !blocked {
// all good, convert it and add it to the results
if acctMasto, err := p.tc.AccountToMastoPublic(foundAccount); err == nil && acctMasto != nil {
results.Accounts = append(results.Accounts, *acctMasto)

View file

@ -34,7 +34,7 @@ func (p *processor) BoostedBy(requestingAccount *gtsmodel.Account, targetStatusI
// filter the list so the user doesn't see accounts they blocked or which blocked them
filteredAccounts := []*gtsmodel.Account{}
for _, s := range statusReblogs {
blocked, err := p.db.Blocked(requestingAccount.ID, s.AccountID, true)
blocked, err := p.db.IsBlocked(requestingAccount.ID, s.AccountID, true)
if err != nil {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("StatusBoostedBy: error checking blocks: %s", err))
}

View file

@ -34,7 +34,7 @@ func (p *processor) FavedBy(requestingAccount *gtsmodel.Account, targetStatusID
// filter the list so the user doesn't see accounts they blocked or which blocked them
filteredAccounts := []*gtsmodel.Account{}
for _, fave := range statusFaves {
blocked, err := p.db.Blocked(requestingAccount.ID, fave.AccountID, true)
blocked, err := p.db.IsBlocked(requestingAccount.ID, fave.AccountID, true)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error checking blocks: %s", err))
}

View file

@ -119,7 +119,7 @@ func (p *processor) ProcessReplyToID(form *apimodel.AdvancedStatusCreateForm, th
return fmt.Errorf("status with id %s not replyable: %s", form.InReplyToID, err)
}
// check if a block exists
if blocked, err := p.db.Blocked(thisAccountID, repliedAccount.ID, true); err != nil {
if blocked, err := p.db.IsBlocked(thisAccountID, repliedAccount.ID, true); err != nil {
if err != db.ErrNoEntries {
return fmt.Errorf("status with id %s not replyable: %s", form.InReplyToID, err)
}

View file

@ -74,7 +74,7 @@ func (p *processor) HomeTimelineGet(authed *oauth.Auth, maxID string, sinceID st
}
func (p *processor) PublicTimelineGet(authed *oauth.Auth, maxID string, sinceID string, minID string, limit int, local bool) (*apimodel.StatusTimelineResponse, gtserror.WithCode) {
statuses, err := p.db.GetPublicTimelineForAccount(authed.Account.ID, maxID, sinceID, minID, limit, local)
statuses, err := p.db.GetPublicTimeline(authed.Account.ID, maxID, sinceID, minID, limit, local)
if err != nil {
if err == db.ErrNoEntries {
// there are just no entries left
@ -95,7 +95,7 @@ func (p *processor) PublicTimelineGet(authed *oauth.Auth, maxID string, sinceID
}
func (p *processor) FavedTimelineGet(authed *oauth.Auth, maxID string, minID string, limit int) (*apimodel.StatusTimelineResponse, gtserror.WithCode) {
statuses, nextMaxID, prevMinID, err := p.db.GetFavedTimelineForAccount(authed.Account.ID, maxID, minID, limit)
statuses, nextMaxID, prevMinID, err := p.db.GetFavedTimeline(authed.Account.ID, maxID, minID, limit)
if err != nil {
if err == db.ErrNoEntries {
// there are just no entries left