diff options
author | 2023-03-01 18:26:53 +0000 | |
---|---|---|
committer | 2023-03-01 18:26:53 +0000 | |
commit | baf933cb9f3e1053bdb61b90d7027efe9fad1bc2 (patch) | |
tree | 3f2a76851d58517ca3dece2bacd6aceefd8dfb96 /internal/processing/instance.go | |
parent | [feature] Federate pinned posts (aka `featuredCollection`) in and out (#1560) (diff) | |
download | gotosocial-baf933cb9f3e1053bdb61b90d7027efe9fad1bc2.tar.xz |
[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 <grufwub@gmail.com>
Reviewed-by: tobi
Diffstat (limited to 'internal/processing/instance.go')
-rw-r--r-- | internal/processing/instance.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/internal/processing/instance.go b/internal/processing/instance.go index c3dc4dcea..3ca807af3 100644 --- a/internal/processing/instance.go +++ b/internal/processing/instance.go @@ -35,7 +35,7 @@ import ( func (p *Processor) getThisInstance(ctx context.Context) (*gtsmodel.Instance, error) { i := >smodel.Instance{} - if err := p.db.GetWhere(ctx, []db.Where{{Key: "domain", Value: config.GetHost()}}, i); err != nil { + if err := p.state.DB.GetWhere(ctx, []db.Where{{Key: "domain", Value: config.GetHost()}}, i); err != nil { return nil, err } return i, nil @@ -73,7 +73,7 @@ func (p *Processor) InstancePeersGet(ctx context.Context, includeSuspended bool, domains := []*apimodel.Domain{} if includeOpen { - instances, err := p.db.GetInstancePeers(ctx, false) + instances, err := p.state.DB.GetInstancePeers(ctx, false) if err != nil && err != db.ErrNoEntries { err = fmt.Errorf("error selecting instance peers: %s", err) return nil, gtserror.NewErrorInternalError(err) @@ -87,7 +87,7 @@ func (p *Processor) InstancePeersGet(ctx context.Context, includeSuspended bool, if includeSuspended { domainBlocks := []*gtsmodel.DomainBlock{} - if err := p.db.GetAll(ctx, &domainBlocks); err != nil && err != db.ErrNoEntries { + if err := p.state.DB.GetAll(ctx, &domainBlocks); err != nil && err != db.ErrNoEntries { return nil, gtserror.NewErrorInternalError(err) } @@ -124,12 +124,12 @@ func (p *Processor) InstancePatch(ctx context.Context, form *apimodel.InstanceSe // fetch the instance entry from the db for processing i := >smodel.Instance{} host := config.GetHost() - if err := p.db.GetWhere(ctx, []db.Where{{Key: "domain", Value: host}}, i); err != nil { + if err := p.state.DB.GetWhere(ctx, []db.Where{{Key: "domain", Value: host}}, i); err != nil { return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error fetching instance %s: %s", host, err)) } // fetch the instance account from the db for processing - ia, err := p.db.GetInstanceAccount(ctx, "") + ia, err := p.state.DB.GetInstanceAccount(ctx, "") if err != nil { return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error fetching instance account %s: %s", host, err)) } @@ -148,12 +148,12 @@ func (p *Processor) InstancePatch(ctx context.Context, form *apimodel.InstanceSe // validate & update site contact account if it's set on the form if form.ContactUsername != nil { // make sure the account with the given username exists in the db - contactAccount, err := p.db.GetAccountByUsernameDomain(ctx, *form.ContactUsername, "") + contactAccount, err := p.state.DB.GetAccountByUsernameDomain(ctx, *form.ContactUsername, "") if err != nil { return nil, gtserror.NewErrorBadRequest(err, fmt.Sprintf("account with username %s not retrievable", *form.ContactUsername)) } // make sure it has a user associated with it - contactUser, err := p.db.GetUserByAccountID(ctx, contactAccount.ID) + contactUser, err := p.state.DB.GetUserByAccountID(ctx, contactAccount.ID) if err != nil { return nil, gtserror.NewErrorBadRequest(err, fmt.Sprintf("user for account with username %s not retrievable", *form.ContactUsername)) } @@ -233,7 +233,7 @@ func (p *Processor) InstancePatch(ctx context.Context, form *apimodel.InstanceSe } else if form.AvatarDescription != nil && ia.AvatarMediaAttachment != nil { // process just the description for the existing avatar ia.AvatarMediaAttachment.Description = *form.AvatarDescription - if err := p.db.UpdateByID(ctx, ia.AvatarMediaAttachment, ia.AvatarMediaAttachmentID, "description"); err != nil { + if err := p.state.DB.UpdateByID(ctx, ia.AvatarMediaAttachment, ia.AvatarMediaAttachmentID, "description"); err != nil { return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error updating instance avatar description: %s", err)) } } @@ -252,13 +252,13 @@ func (p *Processor) InstancePatch(ctx context.Context, form *apimodel.InstanceSe if updateInstanceAccount { // if either avatar or header is updated, we need // to update the instance account that stores them - if err := p.db.UpdateAccount(ctx, ia); err != nil { + if err := p.state.DB.UpdateAccount(ctx, ia); err != nil { return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error updating instance account: %s", err)) } } if len(updatingColumns) != 0 { - if err := p.db.UpdateByID(ctx, i, i.ID, updatingColumns...); err != nil { + if err := p.state.DB.UpdateByID(ctx, i, i.ID, updatingColumns...); err != nil { return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error updating instance %s: %s", host, err)) } } |