From baf933cb9f3e1053bdb61b90d7027efe9fad1bc2 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Wed, 1 Mar 2023 18:26:53 +0000 Subject: [chore] move client/federator workerpools to Workers{} (#1575) * replace concurrency worker pools with base models in State.Workers, update code and tests accordingly * improve code comment * change back testrig default log level * un-comment-out TestAnnounceTwice() and fix --------- Signed-off-by: kim Reviewed-by: tobi --- internal/processing/followrequest.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'internal/processing/followrequest.go') diff --git a/internal/processing/followrequest.go b/internal/processing/followrequest.go index 1f1b7f3c2..9bd13cc0b 100644 --- a/internal/processing/followrequest.go +++ b/internal/processing/followrequest.go @@ -30,7 +30,7 @@ import ( ) func (p *Processor) FollowRequestsGet(ctx context.Context, auth *oauth.Auth) ([]apimodel.Account, gtserror.WithCode) { - frs, err := p.db.GetAccountFollowRequests(ctx, auth.Account.ID) + frs, err := p.state.DB.GetAccountFollowRequests(ctx, auth.Account.ID) if err != nil { if err != db.ErrNoEntries { return nil, gtserror.NewErrorInternalError(err) @@ -40,7 +40,7 @@ func (p *Processor) FollowRequestsGet(ctx context.Context, auth *oauth.Auth) ([] accts := []apimodel.Account{} for _, fr := range frs { if fr.Account == nil { - frAcct, err := p.db.GetAccountByID(ctx, fr.AccountID) + frAcct, err := p.state.DB.GetAccountByID(ctx, fr.AccountID) if err != nil { return nil, gtserror.NewErrorInternalError(err) } @@ -57,13 +57,13 @@ func (p *Processor) FollowRequestsGet(ctx context.Context, auth *oauth.Auth) ([] } func (p *Processor) FollowRequestAccept(ctx context.Context, auth *oauth.Auth, accountID string) (*apimodel.Relationship, gtserror.WithCode) { - follow, err := p.db.AcceptFollowRequest(ctx, accountID, auth.Account.ID) + follow, err := p.state.DB.AcceptFollowRequest(ctx, accountID, auth.Account.ID) if err != nil { return nil, gtserror.NewErrorNotFound(err) } if follow.Account == nil { - followAccount, err := p.db.GetAccountByID(ctx, follow.AccountID) + followAccount, err := p.state.DB.GetAccountByID(ctx, follow.AccountID) if err != nil { return nil, gtserror.NewErrorInternalError(err) } @@ -71,14 +71,14 @@ func (p *Processor) FollowRequestAccept(ctx context.Context, auth *oauth.Auth, a } if follow.TargetAccount == nil { - followTargetAccount, err := p.db.GetAccountByID(ctx, follow.TargetAccountID) + followTargetAccount, err := p.state.DB.GetAccountByID(ctx, follow.TargetAccountID) if err != nil { return nil, gtserror.NewErrorInternalError(err) } follow.TargetAccount = followTargetAccount } - p.clientWorker.Queue(messages.FromClientAPI{ + p.state.Workers.EnqueueClientAPI(ctx, messages.FromClientAPI{ APObjectType: ap.ActivityFollow, APActivityType: ap.ActivityAccept, GTSModel: follow, @@ -86,7 +86,7 @@ func (p *Processor) FollowRequestAccept(ctx context.Context, auth *oauth.Auth, a TargetAccount: follow.TargetAccount, }) - gtsR, err := p.db.GetRelationship(ctx, auth.Account.ID, accountID) + gtsR, err := p.state.DB.GetRelationship(ctx, auth.Account.ID, accountID) if err != nil { return nil, gtserror.NewErrorInternalError(err) } @@ -100,13 +100,13 @@ func (p *Processor) FollowRequestAccept(ctx context.Context, auth *oauth.Auth, a } func (p *Processor) FollowRequestReject(ctx context.Context, auth *oauth.Auth, accountID string) (*apimodel.Relationship, gtserror.WithCode) { - followRequest, err := p.db.RejectFollowRequest(ctx, accountID, auth.Account.ID) + followRequest, err := p.state.DB.RejectFollowRequest(ctx, accountID, auth.Account.ID) if err != nil { return nil, gtserror.NewErrorNotFound(err) } if followRequest.Account == nil { - a, err := p.db.GetAccountByID(ctx, followRequest.AccountID) + a, err := p.state.DB.GetAccountByID(ctx, followRequest.AccountID) if err != nil { return nil, gtserror.NewErrorInternalError(err) } @@ -114,14 +114,14 @@ func (p *Processor) FollowRequestReject(ctx context.Context, auth *oauth.Auth, a } if followRequest.TargetAccount == nil { - a, err := p.db.GetAccountByID(ctx, followRequest.TargetAccountID) + a, err := p.state.DB.GetAccountByID(ctx, followRequest.TargetAccountID) if err != nil { return nil, gtserror.NewErrorInternalError(err) } followRequest.TargetAccount = a } - p.clientWorker.Queue(messages.FromClientAPI{ + p.state.Workers.EnqueueClientAPI(ctx, messages.FromClientAPI{ APObjectType: ap.ActivityFollow, APActivityType: ap.ActivityReject, GTSModel: followRequest, @@ -129,7 +129,7 @@ func (p *Processor) FollowRequestReject(ctx context.Context, auth *oauth.Auth, a TargetAccount: followRequest.TargetAccount, }) - gtsR, err := p.db.GetRelationship(ctx, auth.Account.ID, accountID) + gtsR, err := p.state.DB.GetRelationship(ctx, auth.Account.ID, accountID) if err != nil { return nil, gtserror.NewErrorInternalError(err) } -- cgit v1.2.3