summaryrefslogtreecommitdiff
path: root/internal/processing/report
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-03-01 18:26:53 +0000
committerLibravatar GitHub <noreply@github.com>2023-03-01 18:26:53 +0000
commitbaf933cb9f3e1053bdb61b90d7027efe9fad1bc2 (patch)
tree3f2a76851d58517ca3dece2bacd6aceefd8dfb96 /internal/processing/report
parent[feature] Federate pinned posts (aka `featuredCollection`) in and out (#1560) (diff)
downloadgotosocial-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/report')
-rw-r--r--internal/processing/report/create.go8
-rw-r--r--internal/processing/report/get.go4
-rw-r--r--internal/processing/report/report.go16
3 files changed, 12 insertions, 16 deletions
diff --git a/internal/processing/report/create.go b/internal/processing/report/create.go
index 726d11666..e0918554e 100644
--- a/internal/processing/report/create.go
+++ b/internal/processing/report/create.go
@@ -41,7 +41,7 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
}
// validate + fetch target account
- targetAccount, err := p.db.GetAccountByID(ctx, form.AccountID)
+ targetAccount, err := p.state.DB.GetAccountByID(ctx, form.AccountID)
if err != nil {
if errors.Is(err, db.ErrNoEntries) {
err = fmt.Errorf("account with ID %s does not exist", form.AccountID)
@@ -52,7 +52,7 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
}
// fetch statuses by IDs given in the report form (noop if no statuses given)
- statuses, err := p.db.GetStatuses(ctx, form.StatusIDs)
+ statuses, err := p.state.DB.GetStatuses(ctx, form.StatusIDs)
if err != nil {
err = fmt.Errorf("db error fetching report target statuses: %w", err)
return nil, gtserror.NewErrorInternalError(err)
@@ -79,11 +79,11 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
Forwarded: &form.Forward,
}
- if err := p.db.PutReport(ctx, report); err != nil {
+ if err := p.state.DB.PutReport(ctx, report); err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
- p.clientWorker.Queue(messages.FromClientAPI{
+ p.state.Workers.EnqueueClientAPI(ctx, messages.FromClientAPI{
APObjectType: ap.ObjectProfile,
APActivityType: ap.ActivityFlag,
GTSModel: report,
diff --git a/internal/processing/report/get.go b/internal/processing/report/get.go
index af2079b8a..0348c397c 100644
--- a/internal/processing/report/get.go
+++ b/internal/processing/report/get.go
@@ -32,7 +32,7 @@ import (
// Get returns the user view of a moderation report, with the given id.
func (p *Processor) Get(ctx context.Context, account *gtsmodel.Account, id string) (*apimodel.Report, gtserror.WithCode) {
- report, err := p.db.GetReportByID(ctx, id)
+ report, err := p.state.DB.GetReportByID(ctx, id)
if err != nil {
if err == db.ErrNoEntries {
return nil, gtserror.NewErrorNotFound(err)
@@ -64,7 +64,7 @@ func (p *Processor) GetMultiple(
minID string,
limit int,
) (*apimodel.PageableResponse, gtserror.WithCode) {
- reports, err := p.db.GetReports(ctx, resolved, account.ID, targetAccountID, maxID, sinceID, minID, limit)
+ reports, err := p.state.DB.GetReports(ctx, resolved, account.ID, targetAccountID, maxID, sinceID, minID, limit)
if err != nil {
if err == db.ErrNoEntries {
return util.EmptyPageableResponse(), nil
diff --git a/internal/processing/report/report.go b/internal/processing/report/report.go
index b5f4b301e..bc634af2e 100644
--- a/internal/processing/report/report.go
+++ b/internal/processing/report/report.go
@@ -19,22 +19,18 @@
package report
import (
- "github.com/superseriousbusiness/gotosocial/internal/concurrency"
- "github.com/superseriousbusiness/gotosocial/internal/db"
- "github.com/superseriousbusiness/gotosocial/internal/messages"
+ "github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
type Processor struct {
- db db.DB
- tc typeutils.TypeConverter
- clientWorker *concurrency.WorkerPool[messages.FromClientAPI]
+ state *state.State
+ tc typeutils.TypeConverter
}
-func New(db db.DB, tc typeutils.TypeConverter, clientWorker *concurrency.WorkerPool[messages.FromClientAPI]) Processor {
+func New(state *state.State, tc typeutils.TypeConverter) Processor {
return Processor{
- tc: tc,
- db: db,
- clientWorker: clientWorker,
+ state: state,
+ tc: tc,
}
}