summaryrefslogtreecommitdiff
path: root/internal/processing
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-09-23 17:44:11 +0100
committerLibravatar GitHub <noreply@github.com>2023-09-23 18:44:11 +0200
commit8f67dd583d86155440e7905ae23083a9fea42f72 (patch)
treee67abf09a53c2d9053df8072b074a026969d93ef /internal/processing
parent[chore] fix typo in slice.go (#2219) (diff)
downloadgotosocial-8f67dd583d86155440e7905ae23083a9fea42f72.tar.xz
[chore] deinterface the typeutils.Converter and update to use state structure (#2217)
* update typeconverter to use state structure * deinterface the typeutils.TypeConverter -> typeutils.Converter * finish copying over old type converter code comments * fix cherry-pick merge issues, fix tests pointing to old typeutils interface type still
Diffstat (limited to 'internal/processing')
-rw-r--r--internal/processing/account/account.go6
-rw-r--r--internal/processing/account/account_test.go4
-rw-r--r--internal/processing/account/block.go2
-rw-r--r--internal/processing/account/bookmarks.go2
-rw-r--r--internal/processing/account/get.go6
-rw-r--r--internal/processing/account/lists.go2
-rw-r--r--internal/processing/account/relationships.go2
-rw-r--r--internal/processing/account/rss.go2
-rw-r--r--internal/processing/account/statuses.go4
-rw-r--r--internal/processing/account/update.go2
-rw-r--r--internal/processing/admin/admin.go6
-rw-r--r--internal/processing/admin/admin_test.go4
-rw-r--r--internal/processing/admin/domainpermission.go2
-rw-r--r--internal/processing/admin/emoji.go16
-rw-r--r--internal/processing/admin/report.go6
-rw-r--r--internal/processing/admin/rule.go13
-rw-r--r--internal/processing/app.go2
-rw-r--r--internal/processing/common/common.go4
-rw-r--r--internal/processing/fedi/collections.go6
-rw-r--r--internal/processing/fedi/emoji.go2
-rw-r--r--internal/processing/fedi/fedi.go6
-rw-r--r--internal/processing/fedi/status.go8
-rw-r--r--internal/processing/fedi/user.go4
-rw-r--r--internal/processing/instance.go8
-rw-r--r--internal/processing/list/get.go2
-rw-r--r--internal/processing/list/list.go10
-rw-r--r--internal/processing/list/util.go2
-rw-r--r--internal/processing/markers/get.go2
-rw-r--r--internal/processing/markers/markers.go10
-rw-r--r--internal/processing/markers/update.go2
-rw-r--r--internal/processing/media/create.go2
-rw-r--r--internal/processing/media/getemoji.go2
-rw-r--r--internal/processing/media/getmedia.go2
-rw-r--r--internal/processing/media/media.go6
-rw-r--r--internal/processing/media/media_test.go4
-rw-r--r--internal/processing/media/unattach.go2
-rw-r--r--internal/processing/media/update.go2
-rw-r--r--internal/processing/processor.go30
-rw-r--r--internal/processing/processor_test.go4
-rw-r--r--internal/processing/report/create.go2
-rw-r--r--internal/processing/report/get.go4
-rw-r--r--internal/processing/report/report.go10
-rw-r--r--internal/processing/search/search.go6
-rw-r--r--internal/processing/search/util.go6
-rw-r--r--internal/processing/status/boost.go4
-rw-r--r--internal/processing/status/common.go2
-rw-r--r--internal/processing/status/fave.go2
-rw-r--r--internal/processing/status/get.go4
-rw-r--r--internal/processing/status/status.go6
-rw-r--r--internal/processing/status/status_test.go6
-rw-r--r--internal/processing/stream/notification_test.go4
-rw-r--r--internal/processing/timeline/faved.go2
-rw-r--r--internal/processing/timeline/home.go4
-rw-r--r--internal/processing/timeline/list.go4
-rw-r--r--internal/processing/timeline/notification.go4
-rw-r--r--internal/processing/timeline/public.go2
-rw-r--r--internal/processing/timeline/tag.go2
-rw-r--r--internal/processing/timeline/timeline.go14
-rw-r--r--internal/processing/workers/federate.go36
-rw-r--r--internal/processing/workers/fromclientapi.go6
-rw-r--r--internal/processing/workers/surface.go2
-rw-r--r--internal/processing/workers/surfacenotify.go4
-rw-r--r--internal/processing/workers/surfacetimeline.go3
-rw-r--r--internal/processing/workers/workers.go8
-rw-r--r--internal/processing/workers/workers_test.go4
65 files changed, 174 insertions, 178 deletions
diff --git a/internal/processing/account/account.go b/internal/processing/account/account.go
index a32a73ac1..4432fd5f3 100644
--- a/internal/processing/account/account.go
+++ b/internal/processing/account/account.go
@@ -37,7 +37,7 @@ type Processor struct {
c *common.Processor
state *state.State
- tc typeutils.TypeConverter
+ converter *typeutils.Converter
mediaManager *media.Manager
oauthServer oauth.Server
filter *visibility.Filter
@@ -50,7 +50,7 @@ type Processor struct {
func New(
common *common.Processor,
state *state.State,
- tc typeutils.TypeConverter,
+ converter *typeutils.Converter,
mediaManager *media.Manager,
oauthServer oauth.Server,
federator federation.Federator,
@@ -60,7 +60,7 @@ func New(
return Processor{
c: common,
state: state,
- tc: tc,
+ converter: converter,
mediaManager: mediaManager,
oauthServer: oauthServer,
filter: filter,
diff --git a/internal/processing/account/account_test.go b/internal/processing/account/account_test.go
index 2e4a64844..a23d324f8 100644
--- a/internal/processing/account/account_test.go
+++ b/internal/processing/account/account_test.go
@@ -43,7 +43,7 @@ type AccountStandardTestSuite struct {
// standard suite interfaces
suite.Suite
db db.DB
- tc typeutils.TypeConverter
+ tc *typeutils.Converter
storage *storage.Driver
state state.State
mediaManager *media.Manager
@@ -88,7 +88,7 @@ func (suite *AccountStandardTestSuite) SetupTest() {
suite.db = testrig.NewTestDB(&suite.state)
suite.state.DB = suite.db
- suite.tc = testrig.NewTestTypeConverter(suite.db)
+ suite.tc = typeutils.NewConverter(&suite.state)
testrig.StartTimelines(
&suite.state,
diff --git a/internal/processing/account/block.go b/internal/processing/account/block.go
index 270048100..58b0328a4 100644
--- a/internal/processing/account/block.go
+++ b/internal/processing/account/block.go
@@ -155,7 +155,7 @@ func (p *Processor) BlocksGet(
for _, block := range blocks {
// Convert target account to frontend API model. (target will never be nil)
- account, err := p.tc.AccountToAPIAccountBlocked(ctx, block.TargetAccount)
+ account, err := p.converter.AccountToAPIAccountBlocked(ctx, block.TargetAccount)
if err != nil {
log.Errorf(ctx, "error converting account to public api account: %v", err)
continue
diff --git a/internal/processing/account/bookmarks.go b/internal/processing/account/bookmarks.go
index c6b0c14c1..88a02786e 100644
--- a/internal/processing/account/bookmarks.go
+++ b/internal/processing/account/bookmarks.go
@@ -67,7 +67,7 @@ func (p *Processor) BookmarksGet(ctx context.Context, requestingAccount *gtsmode
}
// Convert the status.
- item, err := p.tc.StatusToAPIStatus(ctx, status, requestingAccount)
+ item, err := p.converter.StatusToAPIStatus(ctx, status, requestingAccount)
if err != nil {
log.Errorf(ctx, "error converting bookmarked status to api: %s", err)
continue
diff --git a/internal/processing/account/get.go b/internal/processing/account/get.go
index ddb7c14e0..500c0c2e5 100644
--- a/internal/processing/account/get.go
+++ b/internal/processing/account/get.go
@@ -80,7 +80,7 @@ func (p *Processor) getFor(ctx context.Context, requestingAccount *gtsmodel.Acco
}
if blocked {
- apiAccount, err := p.tc.AccountToAPIAccountBlocked(ctx, targetAccount)
+ apiAccount, err := p.converter.AccountToAPIAccountBlocked(ctx, targetAccount)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting account: %w", err))
}
@@ -107,9 +107,9 @@ func (p *Processor) getFor(ctx context.Context, requestingAccount *gtsmodel.Acco
var apiAccount *apimodel.Account
if requestingAccount != nil && targetAccount.ID == requestingAccount.ID {
- apiAccount, err = p.tc.AccountToAPIAccountSensitive(ctx, targetAccount)
+ apiAccount, err = p.converter.AccountToAPIAccountSensitive(ctx, targetAccount)
} else {
- apiAccount, err = p.tc.AccountToAPIAccountPublic(ctx, targetAccount)
+ apiAccount, err = p.converter.AccountToAPIAccountPublic(ctx, targetAccount)
}
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting account: %w", err))
diff --git a/internal/processing/account/lists.go b/internal/processing/account/lists.go
index 167ed3358..12fbb884b 100644
--- a/internal/processing/account/lists.go
+++ b/internal/processing/account/lists.go
@@ -94,7 +94,7 @@ func (p *Processor) ListsGet(ctx context.Context, requestingAccount *gtsmodel.Ac
continue
}
- apiList, err := p.tc.ListToAPIList(ctx, list)
+ apiList, err := p.converter.ListToAPIList(ctx, list)
if err != nil {
log.Debugf(ctx, "skipping list %s due to error %q", listEntry.ListID, err)
continue
diff --git a/internal/processing/account/relationships.go b/internal/processing/account/relationships.go
index 58c98f3ba..b9e9086c9 100644
--- a/internal/processing/account/relationships.go
+++ b/internal/processing/account/relationships.go
@@ -130,7 +130,7 @@ func (p *Processor) RelationshipGet(ctx context.Context, requestingAccount *gtsm
return nil, gtserror.NewErrorInternalError(gtserror.Newf("error getting relationship: %s", err))
}
- r, err := p.tc.RelationshipToAPIRelationship(ctx, gtsR)
+ r, err := p.converter.RelationshipToAPIRelationship(ctx, gtsR)
if err != nil {
return nil, gtserror.NewErrorInternalError(gtserror.Newf("error converting relationship: %s", err))
}
diff --git a/internal/processing/account/rss.go b/internal/processing/account/rss.go
index ddc07b9ad..df49af21f 100644
--- a/internal/processing/account/rss.go
+++ b/internal/processing/account/rss.go
@@ -122,7 +122,7 @@ func (p *Processor) GetRSSFeedForUsername(ctx context.Context, username string)
// Add each status to the rss feed.
for _, status := range statuses {
- item, err := p.tc.StatusToRSSItem(ctx, status)
+ item, err := p.converter.StatusToRSSItem(ctx, status)
if err != nil {
err = gtserror.Newf("error converting status to feed item: %w", err)
return "", gtserror.NewErrorInternalError(err)
diff --git a/internal/processing/account/statuses.go b/internal/processing/account/statuses.go
index 26684265c..99e9edbcf 100644
--- a/internal/processing/account/statuses.go
+++ b/internal/processing/account/statuses.go
@@ -103,7 +103,7 @@ func (p *Processor) StatusesGet(
for _, s := range filtered {
// Convert filtered statuses to API statuses.
- item, err := p.tc.StatusToAPIStatus(ctx, s, requestingAccount)
+ item, err := p.converter.StatusToAPIStatus(ctx, s, requestingAccount)
if err != nil {
log.Errorf(ctx, "error convering to api status: %v", err)
continue
@@ -173,7 +173,7 @@ func (p *Processor) WebStatusesGet(ctx context.Context, targetAccountID string,
for _, s := range statuses {
// Convert fetched statuses to API statuses.
- item, err := p.tc.StatusToAPIStatus(ctx, s, nil)
+ item, err := p.converter.StatusToAPIStatus(ctx, s, nil)
if err != nil {
log.Errorf(ctx, "error convering to api status: %v", err)
continue
diff --git a/internal/processing/account/update.go b/internal/processing/account/update.go
index ec343f160..81485e165 100644
--- a/internal/processing/account/update.go
+++ b/internal/processing/account/update.go
@@ -274,7 +274,7 @@ func (p *Processor) Update(ctx context.Context, account *gtsmodel.Account, form
OriginAccount: account,
})
- acctSensitive, err := p.tc.AccountToAPIAccountSensitive(ctx, account)
+ acctSensitive, err := p.converter.AccountToAPIAccountSensitive(ctx, account)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("could not convert account into apisensitive account: %s", err))
}
diff --git a/internal/processing/admin/admin.go b/internal/processing/admin/admin.go
index 7353c0da8..51429c11c 100644
--- a/internal/processing/admin/admin.go
+++ b/internal/processing/admin/admin.go
@@ -30,7 +30,7 @@ import (
type Processor struct {
state *state.State
cleaner *cleaner.Cleaner
- tc typeutils.TypeConverter
+ converter *typeutils.Converter
mediaManager *media.Manager
transportController transport.Controller
emailSender email.Sender
@@ -45,11 +45,11 @@ func (p *Processor) Actions() *Actions {
}
// New returns a new admin processor.
-func New(state *state.State, tc typeutils.TypeConverter, mediaManager *media.Manager, transportController transport.Controller, emailSender email.Sender) Processor {
+func New(state *state.State, converter *typeutils.Converter, mediaManager *media.Manager, transportController transport.Controller, emailSender email.Sender) Processor {
return Processor{
state: state,
cleaner: cleaner.New(state),
- tc: tc,
+ converter: converter,
mediaManager: mediaManager,
transportController: transportController,
emailSender: emailSender,
diff --git a/internal/processing/admin/admin_test.go b/internal/processing/admin/admin_test.go
index c1c4d46c2..689f33f46 100644
--- a/internal/processing/admin/admin_test.go
+++ b/internal/processing/admin/admin_test.go
@@ -40,7 +40,7 @@ type AdminStandardTestSuite struct {
// standard suite interfaces
suite.Suite
db db.DB
- tc typeutils.TypeConverter
+ tc *typeutils.Converter
storage *storage.Driver
state state.State
mediaManager *media.Manager
@@ -86,7 +86,7 @@ func (suite *AdminStandardTestSuite) SetupTest() {
suite.db = testrig.NewTestDB(&suite.state)
suite.state.DB = suite.db
- suite.tc = testrig.NewTestTypeConverter(suite.db)
+ suite.tc = typeutils.NewConverter(&suite.state)
testrig.StartTimelines(
&suite.state,
diff --git a/internal/processing/admin/domainpermission.go b/internal/processing/admin/domainpermission.go
index c759c0f11..bedaf6a11 100644
--- a/internal/processing/admin/domainpermission.go
+++ b/internal/processing/admin/domainpermission.go
@@ -40,7 +40,7 @@ func (p *Processor) apiDomainPerm(
domainPermission gtsmodel.DomainPermission,
export bool,
) (*apimodel.DomainPermission, gtserror.WithCode) {
- apiDomainPerm, err := p.tc.DomainPermToAPIDomainPerm(ctx, domainPermission, export)
+ apiDomainPerm, err := p.converter.DomainPermToAPIDomainPerm(ctx, domainPermission, export)
if err != nil {
err := gtserror.NewfAt(3, "error converting domain permission to api model: %w", err)
return nil, gtserror.NewErrorInternalError(err)
diff --git a/internal/processing/admin/emoji.go b/internal/processing/admin/emoji.go
index 96b0bef07..568c4350b 100644
--- a/internal/processing/admin/emoji.go
+++ b/internal/processing/admin/emoji.go
@@ -84,7 +84,7 @@ func (p *Processor) EmojiCreate(ctx context.Context, account *gtsmodel.Account,
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error loading emoji: %s", err), "error loading emoji")
}
- apiEmoji, err := p.tc.EmojiToAPIEmoji(ctx, emoji)
+ apiEmoji, err := p.converter.EmojiToAPIEmoji(ctx, emoji)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting emoji: %s", err), "error converting emoji to api representation")
}
@@ -122,7 +122,7 @@ func (p *Processor) EmojisGet(
items := make([]interface{}, 0, count)
for _, emoji := range emojis {
- adminEmoji, err := p.tc.EmojiToAdminAPIEmoji(ctx, emoji)
+ adminEmoji, err := p.converter.EmojiToAdminAPIEmoji(ctx, emoji)
if err != nil {
err := fmt.Errorf("EmojisGet: error converting emoji to admin model emoji: %s", err)
return nil, gtserror.NewErrorInternalError(err)
@@ -185,7 +185,7 @@ func (p *Processor) EmojiGet(ctx context.Context, account *gtsmodel.Account, use
return nil, gtserror.NewErrorInternalError(err)
}
- adminEmoji, err := p.tc.EmojiToAdminAPIEmoji(ctx, emoji)
+ adminEmoji, err := p.converter.EmojiToAdminAPIEmoji(ctx, emoji)
if err != nil {
err = fmt.Errorf("EmojiGet: error converting emoji to admin api emoji: %s", err)
return nil, gtserror.NewErrorInternalError(err)
@@ -211,7 +211,7 @@ func (p *Processor) EmojiDelete(ctx context.Context, id string) (*apimodel.Admin
return nil, gtserror.NewErrorBadRequest(err, err.Error())
}
- adminEmoji, err := p.tc.EmojiToAdminAPIEmoji(ctx, emoji)
+ adminEmoji, err := p.converter.EmojiToAdminAPIEmoji(ctx, emoji)
if err != nil {
err = fmt.Errorf("EmojiDelete: error converting emoji to admin api emoji: %s", err)
return nil, gtserror.NewErrorInternalError(err)
@@ -260,7 +260,7 @@ func (p *Processor) EmojiCategoriesGet(ctx context.Context) ([]*apimodel.EmojiCa
apiCategories := make([]*apimodel.EmojiCategory, 0, len(categories))
for _, category := range categories {
- apiCategory, err := p.tc.EmojiCategoryToAPIEmojiCategory(ctx, category)
+ apiCategory, err := p.converter.EmojiCategoryToAPIEmojiCategory(ctx, category)
if err != nil {
err := fmt.Errorf("EmojiCategoriesGet: error converting emoji category to api emoji category: %s", err)
return nil, gtserror.NewErrorInternalError(err)
@@ -367,7 +367,7 @@ func (p *Processor) emojiUpdateCopy(ctx context.Context, emoji *gtsmodel.Emoji,
return nil, gtserror.NewErrorInternalError(err)
}
- adminEmoji, err := p.tc.EmojiToAdminAPIEmoji(ctx, newEmoji)
+ adminEmoji, err := p.converter.EmojiToAdminAPIEmoji(ctx, newEmoji)
if err != nil {
err = fmt.Errorf("emojiUpdateCopy: error converting updated emoji %s to admin emoji: %s", emoji.ID, err)
return nil, gtserror.NewErrorInternalError(err)
@@ -391,7 +391,7 @@ func (p *Processor) emojiUpdateDisable(ctx context.Context, emoji *gtsmodel.Emoj
return nil, gtserror.NewErrorInternalError(err)
}
- adminEmoji, err := p.tc.EmojiToAdminAPIEmoji(ctx, emoji)
+ adminEmoji, err := p.converter.EmojiToAdminAPIEmoji(ctx, emoji)
if err != nil {
err = fmt.Errorf("emojiUpdateDisable: error converting updated emoji %s to admin emoji: %s", emoji.ID, err)
return nil, gtserror.NewErrorInternalError(err)
@@ -472,7 +472,7 @@ func (p *Processor) emojiUpdateModify(ctx context.Context, emoji *gtsmodel.Emoji
}
}
- adminEmoji, err := p.tc.EmojiToAdminAPIEmoji(ctx, emoji)
+ adminEmoji, err := p.converter.EmojiToAdminAPIEmoji(ctx, emoji)
if err != nil {
err = fmt.Errorf("emojiUpdateModify: error converting updated emoji %s to admin emoji: %s", emoji.ID, err)
return nil, gtserror.NewErrorInternalError(err)
diff --git a/internal/processing/admin/report.go b/internal/processing/admin/report.go
index e99cc2ec0..0f47cf839 100644
--- a/internal/processing/admin/report.go
+++ b/internal/processing/admin/report.go
@@ -58,7 +58,7 @@ func (p *Processor) ReportsGet(
prevMinIDValue := reports[0].ID
for _, r := range reports {
- item, err := p.tc.ReportToAdminAPIReport(ctx, r, account)
+ item, err := p.converter.ReportToAdminAPIReport(ctx, r, account)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting report to api: %s", err))
}
@@ -96,7 +96,7 @@ func (p *Processor) ReportGet(ctx context.Context, account *gtsmodel.Account, id
return nil, gtserror.NewErrorInternalError(err)
}
- apimodelReport, err := p.tc.ReportToAdminAPIReport(ctx, report, account)
+ apimodelReport, err := p.converter.ReportToAdminAPIReport(ctx, report, account)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@@ -144,7 +144,7 @@ func (p *Processor) ReportResolve(ctx context.Context, account *gtsmodel.Account
TargetAccount: report.Account,
})
- apimodelReport, err := p.tc.ReportToAdminAPIReport(ctx, updatedReport, account)
+ apimodelReport, err := p.converter.ReportToAdminAPIReport(ctx, updatedReport, account)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
diff --git a/internal/processing/admin/rule.go b/internal/processing/admin/rule.go
index 40a2bdcf3..d1ee63cc8 100644
--- a/internal/processing/admin/rule.go
+++ b/internal/processing/admin/rule.go
@@ -35,7 +35,6 @@ func (p *Processor) RulesGet(
ctx context.Context,
) ([]*apimodel.AdminInstanceRule, gtserror.WithCode) {
rules, err := p.state.DB.GetActiveRules(ctx)
-
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@@ -43,7 +42,7 @@ func (p *Processor) RulesGet(
apiRules := make([]*apimodel.AdminInstanceRule, len(rules))
for i := range rules {
- apiRules[i] = p.tc.InstanceRuleToAdminAPIRule(&rules[i])
+ apiRules[i] = p.converter.InstanceRuleToAdminAPIRule(&rules[i])
}
return apiRules, nil
@@ -59,7 +58,7 @@ func (p *Processor) RuleGet(ctx context.Context, id string) (*apimodel.AdminInst
return nil, gtserror.NewErrorInternalError(err)
}
- return p.tc.InstanceRuleToAdminAPIRule(rule), nil
+ return p.converter.InstanceRuleToAdminAPIRule(rule), nil
}
// RuleCreate adds a new rule to the instance.
@@ -78,7 +77,7 @@ func (p *Processor) RuleCreate(ctx context.Context, form *apimodel.InstanceRuleC
return nil, gtserror.NewErrorInternalError(err)
}
- return p.tc.InstanceRuleToAdminAPIRule(rule), nil
+ return p.converter.InstanceRuleToAdminAPIRule(rule), nil
}
// RuleUpdate updates text for an existing rule.
@@ -96,12 +95,11 @@ func (p *Processor) RuleUpdate(ctx context.Context, id string, form *apimodel.In
rule.Text = form.Text
updatedRule, err := p.state.DB.UpdateRule(ctx, rule)
-
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
- return p.tc.InstanceRuleToAdminAPIRule(updatedRule), nil
+ return p.converter.InstanceRuleToAdminAPIRule(updatedRule), nil
}
// RuleDelete deletes an existing rule.
@@ -118,10 +116,9 @@ func (p *Processor) RuleDelete(ctx context.Context, id string) (*apimodel.AdminI
rule.Deleted = util.Ptr(true)
deletedRule, err := p.state.DB.UpdateRule(ctx, rule)
-
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
- return p.tc.InstanceRuleToAdminAPIRule(deletedRule), nil
+ return p.converter.InstanceRuleToAdminAPIRule(deletedRule), nil
}
diff --git a/internal/processing/app.go b/internal/processing/app.go
index d4a923e8a..eef4fae0d 100644
--- a/internal/processing/app.go
+++ b/internal/processing/app.go
@@ -79,7 +79,7 @@ func (p *Processor) AppCreate(ctx context.Context, authed *oauth.Auth, form *api
return nil, gtserror.NewErrorInternalError(err)
}
- apiApp, err := p.tc.AppToAPIAppSensitive(ctx, app)
+ apiApp, err := p.converter.AppToAPIAppSensitive(ctx, app)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
diff --git a/internal/processing/common/common.go b/internal/processing/common/common.go
index 53c298579..28fadc2a6 100644
--- a/internal/processing/common/common.go
+++ b/internal/processing/common/common.go
@@ -29,7 +29,7 @@ import (
// processing subsection of the codebase.
type Processor struct {
state *state.State
- converter typeutils.TypeConverter
+ converter *typeutils.Converter
federator federation.Federator
filter *visibility.Filter
}
@@ -37,7 +37,7 @@ type Processor struct {
// New returns a new Processor instance.
func New(
state *state.State,
- converter typeutils.TypeConverter,
+ converter *typeutils.Converter,
federator federation.Federator,
filter *visibility.Filter,
) Processor {
diff --git a/internal/processing/fedi/collections.go b/internal/processing/fedi/collections.go
index 5f9c117e1..cbabbfdd6 100644
--- a/internal/processing/fedi/collections.go
+++ b/internal/processing/fedi/collections.go
@@ -70,7 +70,7 @@ func (p *Processor) OutboxGet(ctx context.Context, requestedUsername string, pag
"last": "https://example.org/users/whatever/outbox?min_id=0&page=true"
}
*/
- collection, err := p.tc.OutboxToASCollection(ctx, requestedAccount.OutboxURI)
+ collection, err := p.converter.OutboxToASCollection(ctx, requestedAccount.OutboxURI)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@@ -90,7 +90,7 @@ func (p *Processor) OutboxGet(ctx context.Context, requestedUsername string, pag
return nil, gtserror.NewErrorInternalError(err)
}
- outboxPage, err := p.tc.StatusesToASOutboxPage(ctx, requestedAccount.OutboxURI, maxID, minID, publicStatuses)
+ outboxPage, err := p.converter.StatusesToASOutboxPage(ctx, requestedAccount.OutboxURI, maxID, minID, publicStatuses)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@@ -301,7 +301,7 @@ func (p *Processor) FeaturedCollectionGet(ctx context.Context, requestedUsername
}
}
- collection, err := p.tc.StatusesToASFeaturedCollection(ctx, requestedAccount.FeaturedCollectionURI, statuses)
+ collection, err := p.converter.StatusesToASFeaturedCollection(ctx, requestedAccount.FeaturedCollectionURI, statuses)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
diff --git a/internal/processing/fedi/emoji.go b/internal/processing/fedi/emoji.go
index ea7cb6082..4acf8c671 100644
--- a/internal/processing/fedi/emoji.go
+++ b/internal/processing/fedi/emoji.go
@@ -44,7 +44,7 @@ func (p *Processor) EmojiGet(ctx context.Context, requestedEmojiID string) (inte
return nil, gtserror.NewErrorNotFound(fmt.Errorf("emoji with id %s has been disabled", requestedEmojiID))
}
- apEmoji, err := p.tc.EmojiToAS(ctx, requestedEmoji)
+ apEmoji, err := p.converter.EmojiToAS(ctx, requestedEmoji)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting gtsmodel emoji with id %s to ap emoji: %s", requestedEmojiID, err))
}
diff --git a/internal/processing/fedi/fedi.go b/internal/processing/fedi/fedi.go
index 92a23a543..9fbcebefc 100644
--- a/internal/processing/fedi/fedi.go
+++ b/internal/processing/fedi/fedi.go
@@ -27,16 +27,16 @@ import (
type Processor struct {
state *state.State
federator federation.Federator
- tc typeutils.TypeConverter
+ converter *typeutils.Converter
filter *visibility.Filter
}
// New returns a new fedi processor.
-func New(state *state.State, tc typeutils.TypeConverter, federator federation.Federator, filter *visibility.Filter) Processor {
+func New(state *state.State, converter *typeutils.Converter, federator federation.Federator, filter *visibility.Filter) Processor {
return Processor{
state: state,
federator: federator,
- tc: tc,
+ converter: converter,
filter: filter,
}
}
diff --git a/internal/processing/fedi/status.go b/internal/processing/fedi/status.go
index c2a0e46d6..9b8c7dd95 100644
--- a/internal/processing/fedi/status.go
+++ b/internal/processing/fedi/status.go
@@ -56,7 +56,7 @@ func (p *Processor) StatusGet(ctx context.Context, requestedUsername string, req
return nil, gtserror.NewErrorNotFound(err)
}
- asStatus, err := p.tc.StatusToAS(ctx, status)
+ asStatus, err := p.converter.StatusToAS(ctx, status)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@@ -104,7 +104,7 @@ func (p *Processor) StatusRepliesGet(ctx context.Context, requestedUsername stri
case !page:
// scenario 1
// get the collection
- collection, err := p.tc.StatusToASRepliesCollection(ctx, status, onlyOtherAccounts)
+ collection, err := p.converter.StatusToASRepliesCollection(ctx, status, onlyOtherAccounts)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@@ -116,7 +116,7 @@ func (p *Processor) StatusRepliesGet(ctx context.Context, requestedUsername stri
case page && !onlyOtherAccountsSet:
// scenario 2
// get the collection
- collection, err := p.tc.StatusToASRepliesCollection(ctx, status, onlyOtherAccounts)
+ collection, err := p.converter.StatusToASRepliesCollection(ctx, status, onlyOtherAccounts)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@@ -166,7 +166,7 @@ func (p *Processor) StatusRepliesGet(ctx context.Context, requestedUsername stri
replyURIs[r.ID] = rURI
}
- repliesPage, err := p.tc.StatusURIsToASRepliesPage(ctx, status, onlyOtherAccounts, minID, replyURIs)
+ repliesPage, err := p.converter.StatusURIsToASRepliesPage(ctx, status, onlyOtherAccounts, minID, replyURIs)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
diff --git a/internal/processing/fedi/user.go b/internal/processing/fedi/user.go
index f3305c103..67f137f25 100644
--- a/internal/processing/fedi/user.go
+++ b/internal/processing/fedi/user.go
@@ -54,7 +54,7 @@ func (p *Processor) UserGet(ctx context.Context, requestedUsername string, reque
// the bare minimum user profile needed for the pubkey.
//
// TODO: https://github.com/superseriousbusiness/gotosocial/issues/1186
- minimalPerson, err := p.tc.AccountToASMinimal(ctx, requestedAccount)
+ minimalPerson, err := p.converter.AccountToASMinimal(ctx, requestedAccount)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@@ -72,7 +72,7 @@ func (p *Processor) UserGet(ctx context.Context, requestedUsername string, reque
}
// Auth passed, generate the proper AP representation.
- person, err := p.tc.AccountToAS(ctx, requestedAccount)
+ person, err := p.converter.AccountToAS(ctx, requestedAccount)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
diff --git a/internal/processing/instance.go b/internal/processing/instance.go
index 2faef7527..caf2b9fc1 100644
--- a/internal/processing/instance.go
+++ b/internal/processing/instance.go
@@ -48,7 +48,7 @@ func (p *Processor) InstanceGetV1(ctx context.Context) (*apimodel.InstanceV1, gt
return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error fetching instance: %s", err))
}
- ai, err := p.tc.InstanceToAPIV1Instance(ctx, i)
+ ai, err := p.converter.InstanceToAPIV1Instance(ctx, i)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting instance to api representation: %s", err))
}
@@ -62,7 +62,7 @@ func (p *Processor) InstanceGetV2(ctx context.Context) (*apimodel.InstanceV2, gt
return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error fetching instance: %s", err))
}
- ai, err := p.tc.InstanceToAPIV2Instance(ctx, i)
+ ai, err := p.converter.InstanceToAPIV2Instance(ctx, i)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting instance to api representation: %s", err))
}
@@ -142,7 +142,7 @@ func (p *Processor) InstanceGetRules(ctx context.Context) ([]apimodel.InstanceRu
return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error fetching instance: %s", err))
}
- return p.tc.InstanceRulesToAPIRules(i.Rules), nil
+ return p.converter.InstanceRulesToAPIRules(i.Rules), nil
}
func (p *Processor) InstancePatch(ctx context.Context, form *apimodel.InstanceSettingsUpdateRequest) (*apimodel.InstanceV1, gtserror.WithCode) {
@@ -289,7 +289,7 @@ func (p *Processor) InstancePatch(ctx context.Context, form *apimodel.InstanceSe
}
}
- ai, err := p.tc.InstanceToAPIV1Instance(ctx, instance)
+ ai, err := p.converter.InstanceToAPIV1Instance(ctx, instance)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting instance to api representation: %s", err))
}
diff --git a/internal/processing/list/get.go b/internal/processing/list/get.go
index 1a03898ed..9a7e7716f 100644
--- a/internal/processing/list/get.go
+++ b/internal/processing/list/get.go
@@ -197,7 +197,7 @@ func (p *Processor) accountsFromListEntries(
continue
}
- apiAccount, err := p.tc.AccountToAPIAccountPublic(ctx, listEntry.Follow.TargetAccount)
+ apiAccount, err := p.converter.AccountToAPIAccountPublic(ctx, listEntry.Follow.TargetAccount)
if err != nil {
log.Errorf(ctx, "error converting to public api account: %v", err)
continue
diff --git a/internal/processing/list/list.go b/internal/processing/list/list.go
index f192beb60..0003816fb 100644
--- a/internal/processing/list/list.go
+++ b/internal/processing/list/list.go
@@ -23,13 +23,13 @@ import (
)
type Processor struct {
- state *state.State
- tc typeutils.TypeConverter
+ state *state.State
+ converter *typeutils.Converter
}
-func New(state *state.State, tc typeutils.TypeConverter) Processor {
+func New(state *state.State, converter *typeutils.Converter) Processor {
return Processor{
- state: state,
- tc: tc,
+ state: state,
+ converter: converter,
}
}
diff --git a/internal/processing/list/util.go b/internal/processing/list/util.go
index 6186f58c7..c5b1e5081 100644
--- a/internal/processing/list/util.go
+++ b/internal/processing/list/util.go
@@ -53,7 +53,7 @@ func (p *Processor) getList(ctx context.Context, accountID string, listID string
// apiList is a shortcut to return the API version of the given
// list, or return an appropriate error if conversion fails.
func (p *Processor) apiList(ctx context.Context, list *gtsmodel.List) (*apimodel.List, gtserror.WithCode) {
- apiList, err := p.tc.ListToAPIList(ctx, list)
+ apiList, err := p.converter.ListToAPIList(ctx, list)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting list to api: %w", err))
}
diff --git a/internal/processing/markers/get.go b/internal/processing/markers/get.go
index dd94376f1..38e8b53dc 100644
--- a/internal/processing/markers/get.go
+++ b/internal/processing/markers/get.go
@@ -45,7 +45,7 @@ func (p *Processor) Get(ctx context.Context, account *gtsmodel.Account, names []
markers = append(markers, marker)
}
- apiMarker, err := p.tc.MarkersToAPIMarker(ctx, markers)
+ apiMarker, err := p.converter.MarkersToAPIMarker(ctx, markers)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting marker to api: %w", err))
}
diff --git a/internal/processing/markers/markers.go b/internal/processing/markers/markers.go
index 7a1215241..8817ed1a7 100644
--- a/internal/processing/markers/markers.go
+++ b/internal/processing/markers/markers.go
@@ -23,13 +23,13 @@ import (
)
type Processor struct {
- state *state.State
- tc typeutils.TypeConverter
+ state *state.State
+ converter *typeutils.Converter
}
-func New(state *state.State, tc typeutils.TypeConverter) Processor {
+func New(state *state.State, converter *typeutils.Converter) Processor {
return Processor{
- state: state,
- tc: tc,
+ state: state,
+ converter: converter,
}
}
diff --git a/internal/processing/markers/update.go b/internal/processing/markers/update.go
index 96eb17833..22fe65faf 100644
--- a/internal/processing/markers/update.go
+++ b/internal/processing/markers/update.go
@@ -39,7 +39,7 @@ func (p *Processor) Update(ctx context.Context, markers []*gtsmodel.Marker) (*ap
}
}
- apiMarker, err := p.tc.MarkersToAPIMarker(ctx, markers)
+ apiMarker, err := p.converter.MarkersToAPIMarker(ctx, markers)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting marker to api: %w", err))
}
diff --git a/internal/processing/media/create.go b/internal/processing/media/create.go
index cdc65dfa4..b8c469dde 100644
--- a/internal/processing/media/create.go
+++ b/internal/processing/media/create.go
@@ -56,7 +56,7 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
return nil, gtserror.NewErrorUnprocessableEntity(err)
}
- apiAttachment, err := p.tc.AttachmentToAPIAttachment(ctx, attachment)
+ apiAttachment, err := p.converter.AttachmentToAPIAttachment(ctx, attachment)
if err != nil {
err := fmt.Errorf("error parsing media attachment to frontend type: %s", err)
return nil, gtserror.NewErrorInternalError(err)
diff --git a/internal/processing/media/getemoji.go b/internal/processing/media/getemoji.go
index aef3482ae..06712756a 100644
--- a/internal/processing/media/getemoji.go
+++ b/internal/processing/media/getemoji.go
@@ -39,7 +39,7 @@ func (p *Processor) GetCustomEmojis(ctx context.Context) ([]*apimodel.Emoji, gts
apiEmojis := make([]*apimodel.Emoji, 0, len(emojis))
for _, gtsEmoji := range emojis {
- apiEmoji, err := p.tc.EmojiToAPIEmoji(ctx, gtsEmoji)
+ apiEmoji, err := p.converter.EmojiToAPIEmoji(ctx, gtsEmoji)
if err != nil {
log.Errorf(ctx, "error converting emoji with id %s: %s", gtsEmoji.ID, err)
continue
diff --git a/internal/processing/media/getmedia.go b/internal/processing/media/getmedia.go
index e815e8bcf..8f5b9d740 100644
--- a/internal/processing/media/getmedia.go
+++ b/internal/processing/media/getmedia.go
@@ -42,7 +42,7 @@ func (p *Processor) Get(ctx context.Context, account *gtsmodel.Account, mediaAtt
return nil, gtserror.NewErrorNotFound(errors.New("attachment not owned by requesting account"))
}
- a, err := p.tc.AttachmentToAPIAttachment(ctx, attachment)
+ a, err := p.converter.AttachmentToAPIAttachment(ctx, attachment)
if err != nil {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("error converting attachment: %s", err))
}
diff --git a/internal/processing/media/media.go b/internal/processing/media/media.go
index cec912874..22c455920 100644
--- a/internal/processing/media/media.go
+++ b/internal/processing/media/media.go
@@ -26,16 +26,16 @@ import (
type Processor struct {
state *state.State
- tc typeutils.TypeConverter
+ converter *typeutils.Converter
mediaManager *media.Manager
transportController transport.Controller
}
// New returns a new media processor.
-func New(state *state.State, tc typeutils.TypeConverter, mediaManager *media.Manager, transportController transport.Controller) Processor {
+func New(state *state.State, converter *typeutils.Converter, mediaManager *media.Manager, transportController transport.Controller) Processor {
return Processor{
state: state,
- tc: tc,
+ converter: converter,
mediaManager: mediaManager,
transportController: transportController,
}
diff --git a/internal/processing/media/media_test.go b/internal/processing/media/media_test.go
index 97e490a9c..523428140 100644
--- a/internal/processing/media/media_test.go
+++ b/internal/processing/media/media_test.go
@@ -34,7 +34,7 @@ type MediaStandardTestSuite struct {
// standard suite interfaces
suite.Suite
db db.DB
- tc typeutils.TypeConverter
+ tc *typeutils.Converter
storage *storage.Driver
state state.State
mediaManager *media.Manager
@@ -73,7 +73,7 @@ func (suite *MediaStandardTestSuite) SetupTest() {
suite.db = testrig.NewTestDB(&suite.state)
suite.state.DB = suite.db
- suite.tc = testrig.NewTestTypeConverter(suite.db)
+ suite.tc = typeutils.NewConverter(&suite.state)
suite.storage = testrig.NewInMemoryStorage()
suite.state.Storage = suite.storage
suite.mediaManager = testrig.NewTestMediaManager(&suite.state)
diff --git a/internal/processing/media/unattach.go b/internal/processing/media/unattach.go
index c6eeac604..ddf2dda20 100644
--- a/internal/processing/media/unattach.go
+++ b/internal/processing/media/unattach.go
@@ -49,7 +49,7 @@ func (p *Processor) Unattach(ctx context.Context, account *gtsmodel.Account, med
return nil, gtserror.NewErrorNotFound(fmt.Errorf("db error updating attachment: %s", err))
}
- a, err := p.tc.AttachmentToAPIAttachment(ctx, attachment)
+ a, err := p.converter.AttachmentToAPIAttachment(ctx, attachment)
if err != nil {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("error converting attachment: %s", err))
}
diff --git a/internal/processing/media/update.go b/internal/processing/media/update.go
index 59ade9ca5..d3a9cfe61 100644
--- a/internal/processing/media/update.go
+++ b/internal/processing/media/update.go
@@ -65,7 +65,7 @@ func (p *Processor) Update(ctx context.Context, account *gtsmodel.Account, media
return nil, gtserror.NewErrorInternalError(fmt.Errorf("database error updating media: %s", err))
}
- a, err := p.tc.AttachmentToAPIAttachment(ctx, attachment)
+ a, err := p.converter.AttachmentToAPIAttachment(ctx, attachment)
if err != nil {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("error converting attachment: %s", err))
}
diff --git a/internal/processing/processor.go b/internal/processing/processor.go
index f814d5a96..92c7974c7 100644
--- a/internal/processing/processor.go
+++ b/internal/processing/processor.go
@@ -49,7 +49,7 @@ import (
// or sub processors will trigger asynchronous processing
// via the workers contained in state.
type Processor struct {
- tc typeutils.TypeConverter
+ converter *typeutils.Converter
oauthServer oauth.Server
state *state.State
@@ -126,7 +126,7 @@ func (p *Processor) Workers() *workers.Processor {
// NewProcessor returns a new Processor.
func NewProcessor(
- tc typeutils.TypeConverter,
+ converter *typeutils.Converter,
federator federation.Federator,
oauthServer oauth.Server,
mediaManager *mm.Manager,
@@ -139,7 +139,7 @@ func NewProcessor(
)
processor := &Processor{
- tc: tc,
+ converter: converter,
oauthServer: oauthServer,
state: state,
}
@@ -148,23 +148,23 @@ func NewProcessor(
//
// Start with sub processors that will
// be required by the workers processor.
- commonProcessor := common.New(state, tc, federator, filter)
- accountProcessor := account.New(&commonProcessor, state, tc, mediaManager, oauthServer, federator, filter, parseMentionFunc)
- mediaProcessor := media.New(state, tc, mediaManager, federator.TransportController())
+ commonProcessor := common.New(state, converter, federator, filter)
+ accountProcessor := account.New(&commonProcessor, state, converter, mediaManager, oauthServer, federator, filter, parseMentionFunc)
+ mediaProcessor := media.New(state, converter, mediaManager, federator.TransportController())
streamProcessor := stream.New(state, oauthServer)
// Instantiate the rest of the sub
// processors + pin them to this struct.
processor.account = accountProcessor
- processor.admin = admin.New(state, tc, mediaManager, federator.TransportController(), emailSender)
- processor.fedi = fedi.New(state, tc, federator, filter)
- processor.list = list.New(state, tc)
- processor.markers = markers.New(state, tc)
+ processor.admin = admin.New(state, converter, mediaManager, federator.TransportController(), emailSender)
+ processor.fedi = fedi.New(state, converter, federator, filter)
+ processor.list = list.New(state, converter)
+ processor.markers = markers.New(state, converter)
processor.media = mediaProcessor
- processor.report = report.New(state, tc)
- processor.timeline = timeline.New(state, tc, filter)
- processor.search = search.New(state, federator, tc, filter)
- processor.status = status.New(state, federator, tc, filter, parseMentionFunc)
+ processor.report = report.New(state, converter)
+ processor.timeline = timeline.New(state, converter, filter)
+ processor.search = search.New(state, federator, converter, filter)
+ processor.status = status.New(state, federator, converter, filter, parseMentionFunc)
processor.stream = streamProcessor
processor.user = user.New(state, emailSender)
@@ -174,7 +174,7 @@ func NewProcessor(
processor.workers = workers.New(
state,
federator,
- tc,
+ converter,
filter,
emailSender,
&accountProcessor,
diff --git a/internal/processing/processor_test.go b/internal/processing/processor_test.go
index 383e1dc9f..15d943e86 100644
--- a/internal/processing/processor_test.go
+++ b/internal/processing/processor_test.go
@@ -44,7 +44,7 @@ type ProcessingStandardTestSuite struct {
storage *storage.Driver
state state.State
mediaManager *media.Manager
- typeconverter typeutils.TypeConverter
+ typeconverter *typeutils.Converter
httpClient *testrig.MockHTTPClient
transportController transport.Controller
federator federation.Federator
@@ -104,7 +104,7 @@ func (suite *ProcessingStandardTestSuite) SetupTest() {
suite.testActivities = testrig.NewTestActivities(suite.testAccounts)
suite.storage = testrig.NewInMemoryStorage()
suite.state.Storage = suite.storage
- suite.typeconverter = testrig.NewTestTypeConverter(suite.db)
+ suite.typeconverter = typeutils.NewConverter(&suite.state)
testrig.StartTimelines(
&suite.state,
diff --git a/internal/processing/report/create.go b/internal/processing/report/create.go
index 48f9c1ee4..c65ae0d52 100644
--- a/internal/processing/report/create.go
+++ b/internal/processing/report/create.go
@@ -99,7 +99,7 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
TargetAccount: targetAccount,
})
- apiReport, err := p.tc.ReportToAPIReport(ctx, report)
+ apiReport, err := p.converter.ReportToAPIReport(ctx, report)
if err != nil {
err = fmt.Errorf("error converting report to frontend representation: %w", err)
return nil, gtserror.NewErrorInternalError(err)
diff --git a/internal/processing/report/get.go b/internal/processing/report/get.go
index f39648832..c5c4fc223 100644
--- a/internal/processing/report/get.go
+++ b/internal/processing/report/get.go
@@ -45,7 +45,7 @@ func (p *Processor) Get(ctx context.Context, account *gtsmodel.Account, id strin
return nil, gtserror.NewErrorNotFound(err)
}
- apiReport, err := p.tc.ReportToAPIReport(ctx, report)
+ apiReport, err := p.converter.ReportToAPIReport(ctx, report)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting report to api: %s", err))
}
@@ -79,7 +79,7 @@ func (p *Processor) GetMultiple(
prevMinIDValue := reports[0].ID
for _, r := range reports {
- item, err := p.tc.ReportToAPIReport(ctx, r)
+ item, err := p.converter.ReportToAPIReport(ctx, r)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting report to api: %s", err))
}
diff --git a/internal/processing/report/report.go b/internal/processing/report/report.go
index 2fb11bc7f..c871172bb 100644
--- a/internal/processing/report/report.go
+++ b/internal/processing/report/report.go
@@ -23,13 +23,13 @@ import (
)
type Processor struct {
- state *state.State
- tc typeutils.TypeConverter
+ state *state.State
+ converter *typeutils.Converter
}
-func New(state *state.State, tc typeutils.TypeConverter) Processor {
+func New(state *state.State, converter *typeutils.Converter) Processor {
return Processor{
- state: state,
- tc: tc,
+ state: state,
+ converter: converter,
}
}
diff --git a/internal/processing/search/search.go b/internal/processing/search/search.go
index 907877789..a7b1d4ad3 100644
--- a/internal/processing/search/search.go
+++ b/internal/processing/search/search.go
@@ -27,16 +27,16 @@ import (
type Processor struct {
state *state.State
federator federation.Federator
- tc typeutils.TypeConverter
+ converter *typeutils.Converter
filter *visibility.Filter
}
// New returns a new status processor.
-func New(state *state.State, federator federation.Federator, tc typeutils.TypeConverter, filter *visibility.Filter) Processor {
+func New(state *state.State, federator federation.Federator, converter *typeutils.Converter, filter *visibility.Filter) Processor {
return Processor{
state: state,
federator: federator,
- tc: tc,
+ converter: converter,
filter: filter,
}
}
diff --git a/internal/processing/search/util.go b/internal/processing/search/util.go
index c0eac0ca3..9d9175246 100644
--- a/internal/processing/search/util.go
+++ b/internal/processing/search/util.go
@@ -70,7 +70,7 @@ func (p *Processor) packageAccounts(
continue
}
- apiAccount, err := p.tc.AccountToAPIAccountPublic(ctx, account)
+ apiAccount, err := p.converter.AccountToAPIAccountPublic(ctx, account)
if err != nil {
log.Debugf(ctx, "skipping account %s because it couldn't be converted to its api representation: %s", account.ID, err)
continue
@@ -105,7 +105,7 @@ func (p *Processor) packageStatuses(
continue
}
- apiStatus, err := p.tc.StatusToAPIStatus(ctx, status, requestingAccount)
+ apiStatus, err := p.converter.StatusToAPIStatus(ctx, status, requestingAccount)
if err != nil {
log.Debugf(ctx, "skipping status %s because it couldn't be converted to its api representation: %s", status.ID, err)
continue
@@ -137,7 +137,7 @@ func (p *Processor) packageHashtags(
} else {
// If API not version 1, provide slice of full tags.
rangeF = func(tag *gtsmodel.Tag) {
- apiTag, err := p.tc.TagToAPITag(ctx, tag, true)
+ apiTag, err := p.converter.TagToAPITag(ctx, tag, true)
if err != nil {
log.Debugf(
ctx,
diff --git a/internal/processing/status/boost.go b/internal/processing/status/boost.go
index eccd81886..d4bdc3f43 100644
--- a/internal/processing/status/boost.go
+++ b/internal/processing/status/boost.go
@@ -63,7 +63,7 @@ func (p *Processor) BoostCreate(ctx context.Context, requestingAccount *gtsmodel
}
// it's visible! it's boostable! so let's boost the FUCK out of it
- boostWrapperStatus, err := p.tc.StatusToBoost(ctx, targetStatus, requestingAccount)
+ boostWrapperStatus, err := p.converter.StatusToBoost(ctx, targetStatus, requestingAccount)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@@ -199,7 +199,7 @@ func (p *Processor) StatusBoostedBy(ctx context.Context, requestingAccount *gtsm
return nil, gtserror.NewErrorNotFound(wrapped)
}
- apiAccount, err := p.tc.AccountToAPIAccountPublic(ctx, account)
+ apiAccount, err := p.converter.AccountToAPIAccountPublic(ctx, account)
if err != nil {
err = fmt.Errorf("BoostedBy: error converting account to api model: %s", err)
return nil, gtserror.NewErrorInternalError(err)
diff --git a/internal/processing/status/common.go b/internal/processing/status/common.go
index e557563f3..71eef70a1 100644
--- a/internal/processing/status/common.go
+++ b/internal/processing/status/common.go
@@ -29,7 +29,7 @@ import (
)
func (p *Processor) apiStatus(ctx context.Context, targetStatus *gtsmodel.Status, requestingAccount *gtsmodel.Account) (*apimodel.Status, gtserror.WithCode) {
- apiStatus, err := p.tc.StatusToAPIStatus(ctx, targetStatus, requestingAccount)
+ apiStatus, err := p.converter.StatusToAPIStatus(ctx, targetStatus, requestingAccount)
if err != nil {
err = gtserror.Newf("error converting status %s to frontend representation: %w", targetStatus.ID, err)
return nil, gtserror.NewErrorInternalError(err)
diff --git a/internal/processing/status/fave.go b/internal/processing/status/fave.go
index 9da243312..e2bf03594 100644
--- a/internal/processing/status/fave.go
+++ b/internal/processing/status/fave.go
@@ -135,7 +135,7 @@ func (p *Processor) FavedBy(ctx context.Context, requestingAccount *gtsmodel.Acc
continue
}
- apiAccount, err := p.tc.AccountToAPIAccountPublic(ctx, fave.Account)
+ apiAccount, err := p.converter.AccountToAPIAccountPublic(ctx, fave.Account)
if err != nil {
err = fmt.Errorf("FavedBy: error converting account %s to frontend representation: %w", fave.AccountID, err)
return nil, gtserror.NewErrorInternalError(err)
diff --git a/internal/processing/status/get.go b/internal/processing/status/get.go
index 236f6f126..cf79b96a0 100644
--- a/internal/processing/status/get.go
+++ b/internal/processing/status/get.go
@@ -55,7 +55,7 @@ func (p *Processor) ContextGet(ctx context.Context, requestingAccount *gtsmodel.
for _, status := range parents {
if v, err := p.filter.StatusVisible(ctx, requestingAccount, status); err == nil && v {
- apiStatus, err := p.tc.StatusToAPIStatus(ctx, status, requestingAccount)
+ apiStatus, err := p.converter.StatusToAPIStatus(ctx, status, requestingAccount)
if err == nil {
context.Ancestors = append(context.Ancestors, *apiStatus)
}
@@ -73,7 +73,7 @@ func (p *Processor) ContextGet(ctx context.Context, requestingAccount *gtsmodel.
for _, status := range children {
if v, err := p.filter.StatusVisible(ctx, requestingAccount, status); err == nil && v {
- apiStatus, err := p.tc.StatusToAPIStatus(ctx, status, requestingAccount)
+ apiStatus, err := p.converter.StatusToAPIStatus(ctx, status, requestingAccount)
if err == nil {
context.Descendants = append(context.Descendants, *apiStatus)
}
diff --git a/internal/processing/status/status.go b/internal/processing/status/status.go
index c34bff30f..bd8457eb8 100644
--- a/internal/processing/status/status.go
+++ b/internal/processing/status/status.go
@@ -29,18 +29,18 @@ import (
type Processor struct {
state *state.State
federator federation.Federator
- tc typeutils.TypeConverter
+ converter *typeutils.Converter
filter *visibility.Filter
formatter text.Formatter
parseMention gtsmodel.ParseMentionFunc
}
// New returns a new status processor.
-func New(state *state.State, federator federation.Federator, tc typeutils.TypeConverter, filter *visibility.Filter, parseMention gtsmodel.ParseMentionFunc) Processor {
+func New(state *state.State, federator federation.Federator, converter *typeutils.Converter, filter *visibility.Filter, parseMention gtsmodel.ParseMentionFunc) Processor {
return Processor{
state: state,
federator: federator,
- tc: tc,
+ converter: converter,
filter: filter,
formatter: text.NewFormatter(state.DB),
parseMention: parseMention,
diff --git a/internal/processing/status/status_test.go b/internal/processing/status/status_test.go
index a64143df4..1f73530cb 100644
--- a/internal/processing/status/status_test.go
+++ b/internal/processing/status/status_test.go
@@ -36,7 +36,7 @@ import (
type StatusStandardTestSuite struct {
suite.Suite
db db.DB
- typeConverter typeutils.TypeConverter
+ typeConverter *typeutils.Converter
tc transport.Controller
storage *storage.Driver
state state.State
@@ -78,7 +78,7 @@ func (suite *StatusStandardTestSuite) SetupTest() {
testrig.InitTestLog()
suite.db = testrig.NewTestDB(&suite.state)
- suite.typeConverter = testrig.NewTestTypeConverter(suite.db)
+ suite.typeConverter = typeutils.NewConverter(&suite.state)
suite.state.DB = suite.db
suite.tc = testrig.NewTestTransportController(&suite.state, testrig.NewMockHTTPClient(nil, "../../../testrig/media"))
@@ -91,7 +91,7 @@ func (suite *StatusStandardTestSuite) SetupTest() {
testrig.StartTimelines(
&suite.state,
filter,
- testrig.NewTestTypeConverter(suite.db),
+ suite.typeConverter,
)
suite.status = status.New(&suite.state, suite.federator, suite.typeConverter, filter, processing.GetParseMentionFunc(suite.db, suite.federator))
diff --git a/internal/processing/stream/notification_test.go b/internal/processing/stream/notification_test.go
index 5db735db7..7ce8b95d5 100644
--- a/internal/processing/stream/notification_test.go
+++ b/internal/processing/stream/notification_test.go
@@ -25,7 +25,7 @@ import (
"github.com/stretchr/testify/suite"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
- "github.com/superseriousbusiness/gotosocial/testrig"
+ "github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
type NotificationTestSuite struct {
@@ -39,7 +39,7 @@ func (suite *NotificationTestSuite) TestStreamNotification() {
suite.NoError(errWithCode)
followAccount := suite.testAccounts["remote_account_1"]
- followAccountAPIModel, err := testrig.NewTestTypeConverter(suite.db).AccountToAPIAccountPublic(context.Background(), followAccount)
+ followAccountAPIModel, err := typeutils.NewConverter(&suite.state).AccountToAPIAccountPublic(context.Background(), followAccount)
suite.NoError(err)
notification := &apimodel.Notification{
diff --git a/internal/processing/timeline/faved.go b/internal/processing/timeline/faved.go
index 556ced4c3..205b15069 100644
--- a/internal/processing/timeline/faved.go
+++ b/internal/processing/timeline/faved.go
@@ -54,7 +54,7 @@ func (p *Processor) FavedTimelineGet(ctx context.Context, authed *oauth.Auth, ma
continue
}
- apiStatus, err := p.tc.StatusToAPIStatus(ctx, s, authed.Account)
+ apiStatus, err := p.converter.StatusToAPIStatus(ctx, s, authed.Account)
if err != nil {
log.Errorf(ctx, "error convering to api status: %v", err)
continue
diff --git a/internal/processing/timeline/home.go b/internal/processing/timeline/home.go
index 72940175f..126c9f668 100644
--- a/internal/processing/timeline/home.go
+++ b/internal/processing/timeline/home.go
@@ -84,7 +84,7 @@ func HomeTimelineFilter(state *state.State, filter *visibility.Filter) timeline.
}
// HomeTimelineStatusPrepare returns a function that satisfies PrepareFunction for home timelines.
-func HomeTimelineStatusPrepare(state *state.State, tc typeutils.TypeConverter) timeline.PrepareFunction {
+func HomeTimelineStatusPrepare(state *state.State, converter *typeutils.Converter) timeline.PrepareFunction {
return func(ctx context.Context, accountID string, itemID string) (timeline.Preparable, error) {
status, err := state.DB.GetStatusByID(ctx, itemID)
if err != nil {
@@ -98,7 +98,7 @@ func HomeTimelineStatusPrepare(state *state.State, tc typeutils.TypeConverter) t
return nil, err
}
- return tc.StatusToAPIStatus(ctx, status, requestingAccount)
+ return converter.StatusToAPIStatus(ctx, status, requestingAccount)
}
}
diff --git a/internal/processing/timeline/list.go b/internal/processing/timeline/list.go
index 80744df15..64de288db 100644
--- a/internal/processing/timeline/list.go
+++ b/internal/processing/timeline/list.go
@@ -90,7 +90,7 @@ func ListTimelineFilter(state *state.State, filter *visibility.Filter) timeline.
}
// ListTimelineStatusPrepare returns a function that satisfies PrepareFunction for list timelines.
-func ListTimelineStatusPrepare(state *state.State, tc typeutils.TypeConverter) timeline.PrepareFunction {
+func ListTimelineStatusPrepare(state *state.State, converter *typeutils.Converter) timeline.PrepareFunction {
return func(ctx context.Context, listID string, itemID string) (timeline.Preparable, error) {
status, err := state.DB.GetStatusByID(ctx, itemID)
if err != nil {
@@ -110,7 +110,7 @@ func ListTimelineStatusPrepare(state *state.State, tc typeutils.TypeConverter) t
return nil, err
}
- return tc.StatusToAPIStatus(ctx, status, requestingAccount)
+ return converter.StatusToAPIStatus(ctx, status, requestingAccount)
}
}
diff --git a/internal/processing/timeline/notification.go b/internal/processing/timeline/notification.go
index 4a79fb82a..09febdb46 100644
--- a/internal/processing/timeline/notification.go
+++ b/internal/processing/timeline/notification.go
@@ -87,7 +87,7 @@ func (p *Processor) NotificationsGet(ctx context.Context, authed *oauth.Auth, ma
}
}
- item, err := p.tc.NotificationToAPINotification(ctx, n)
+ item, err := p.converter.NotificationToAPINotification(ctx, n)
if err != nil {
log.Debugf(ctx, "skipping notification %s because it couldn't be converted to its api representation: %s", n.ID, err)
continue
@@ -121,7 +121,7 @@ func (p *Processor) NotificationGet(ctx context.Context, account *gtsmodel.Accou
return nil, gtserror.NewErrorNotFound(err)
}
- apiNotif, err := p.tc.NotificationToAPINotification(ctx, notif)
+ apiNotif, err := p.converter.NotificationToAPINotification(ctx, notif)
if err != nil {
if errors.Is(err, db.ErrNoEntries) {
return nil, gtserror.NewErrorNotFound(err)
diff --git a/internal/processing/timeline/public.go b/internal/processing/timeline/public.go
index 78ca56734..eb8c0c381 100644
--- a/internal/processing/timeline/public.go
+++ b/internal/processing/timeline/public.go
@@ -62,7 +62,7 @@ func (p *Processor) PublicTimelineGet(ctx context.Context, authed *oauth.Auth, m
continue
}
- apiStatus, err := p.tc.StatusToAPIStatus(ctx, s, authed.Account)
+ apiStatus, err := p.converter.StatusToAPIStatus(ctx, s, authed.Account)
if err != nil {
log.Errorf(ctx, "error convert to api status: %v", err)
continue
diff --git a/internal/processing/timeline/tag.go b/internal/processing/timeline/tag.go
index 943aa1722..45632ce06 100644
--- a/internal/processing/timeline/tag.go
+++ b/internal/processing/timeline/tag.go
@@ -122,7 +122,7 @@ func (p *Processor) packageTagResponse(
continue
}
- apiStatus, err := p.tc.StatusToAPIStatus(ctx, s, requestingAcct)
+ apiStatus, err := p.converter.StatusToAPIStatus(ctx, s, requestingAcct)
if err != nil {
log.Errorf(ctx, "error converting to api status: %v", err)
continue
diff --git a/internal/processing/timeline/timeline.go b/internal/processing/timeline/timeline.go
index 7a95f9a11..bf9864398 100644
--- a/internal/processing/timeline/timeline.go
+++ b/internal/processing/timeline/timeline.go
@@ -24,15 +24,15 @@ import (
)
type Processor struct {
- state *state.State
- tc typeutils.TypeConverter
- filter *visibility.Filter
+ state *state.State
+ converter *typeutils.Converter
+ filter *visibility.Filter
}
-func New(state *state.State, tc typeutils.TypeConverter, filter *visibility.Filter) Processor {
+func New(state *state.State, converter *typeutils.Converter, filter *visibility.Filter) Processor {
return Processor{
- state: state,
- tc: tc,
- filter: filter,
+ state: state,
+ converter: converter,
+ filter: filter,
}
}
diff --git a/internal/processing/workers/federate.go b/internal/processing/workers/federate.go
index 76bfc892e..4b2ca4de1 100644
--- a/internal/processing/workers/federate.go
+++ b/internal/processing/workers/federate.go
@@ -37,8 +37,8 @@ type federate struct {
// Embed federator to give access
// to send and retrieve functions.
federation.Federator
- state *state.State
- tc typeutils.TypeConverter
+ state *state.State
+ converter *typeutils.Converter
}
// parseURI is a cheeky little
@@ -160,12 +160,12 @@ func (f *federate) CreateStatus(ctx context.Context, status *gtsmodel.Status) er
// Convert status to an ActivityStreams
// Note, wrapped in a Create activity.
- asStatus, err := f.tc.StatusToAS(ctx, status)
+ asStatus, err := f.converter.StatusToAS(ctx, status)
if err != nil {
return gtserror.Newf("error converting status to AS: %w", err)
}
- create, err := f.tc.WrapNoteInCreate(asStatus, false)
+ create, err := f.converter.WrapNoteInCreate(asStatus, false)
if err != nil {
return gtserror.Newf("error wrapping status in create: %w", err)
}
@@ -208,7 +208,7 @@ func (f *federate) DeleteStatus(ctx context.Context, status *gtsmodel.Status) er
}
// Wrap the status URI in a Delete activity.
- delete, err := f.tc.StatusToASDelete(ctx, status)
+ delete, err := f.converter.StatusToASDelete(ctx, status)
if err != nil {
return gtserror.Newf("error creating Delete: %w", err)
}
@@ -245,7 +245,7 @@ func (f *federate) Follow(ctx context.Context, follow *gtsmodel.Follow) error {
}
// Convert follow to ActivityStreams Follow.
- asFollow, err := f.tc.FollowToAS(ctx, follow)
+ asFollow, err := f.converter.FollowToAS(ctx, follow)
if err != nil {
return gtserror.Newf("error converting follow to AS: %s", err)
}
@@ -287,7 +287,7 @@ func (f *federate) UndoFollow(ctx context.Context, follow *gtsmodel.Follow) erro
}
// Recreate the ActivityStreams Follow.
- asFollow, err := f.tc.FollowToAS(ctx, follow)
+ asFollow, err := f.converter.FollowToAS(ctx, follow)
if err != nil {
return gtserror.Newf("error converting follow to AS: %w", err)
}
@@ -351,7 +351,7 @@ func (f *federate) UndoLike(ctx context.Context, fave *gtsmodel.StatusFave) erro
}
// Recreate the ActivityStreams Like.
- like, err := f.tc.FaveToAS(ctx, fave)
+ like, err := f.converter.FaveToAS(ctx, fave)
if err != nil {
return gtserror.Newf("error converting fave to AS: %w", err)
}
@@ -410,7 +410,7 @@ func (f *federate) UndoAnnounce(ctx context.Context, boost *gtsmodel.Status) err
}
// Recreate the ActivityStreams Announce.
- asAnnounce, err := f.tc.BoostToAS(
+ asAnnounce, err := f.converter.BoostToAS(
ctx,
boost,
boost.Account,
@@ -493,7 +493,7 @@ func (f *federate) AcceptFollow(ctx context.Context, follow *gtsmodel.Follow) er
}
// Recreate the ActivityStreams Follow.
- asFollow, err := f.tc.FollowToAS(ctx, follow)
+ asFollow, err := f.converter.FollowToAS(ctx, follow)
if err != nil {
return gtserror.Newf("error converting follow to AS: %w", err)
}
@@ -571,7 +571,7 @@ func (f *federate) RejectFollow(ctx context.Context, follow *gtsmodel.Follow) er
}
// Recreate the ActivityStreams Follow.
- asFollow, err := f.tc.FollowToAS(ctx, follow)
+ asFollow, err := f.converter.FollowToAS(ctx, follow)
if err != nil {
return gtserror.Newf("error converting follow to AS: %w", err)
}
@@ -631,7 +631,7 @@ func (f *federate) Like(ctx context.Context, fave *gtsmodel.StatusFave) error {
}
// Create the ActivityStreams Like.
- like, err := f.tc.FaveToAS(ctx, fave)
+ like, err := f.converter.FaveToAS(ctx, fave)
if err != nil {
return gtserror.Newf("error converting fave to AS Like: %w", err)
}
@@ -668,7 +668,7 @@ func (f *federate) Announce(ctx context.Context, boost *gtsmodel.Status) error {
}
// Create the ActivityStreams Announce.
- announce, err := f.tc.BoostToAS(
+ announce, err := f.converter.BoostToAS(
ctx,
boost,
boost.Account,
@@ -704,13 +704,13 @@ func (f *federate) UpdateAccount(ctx context.Context, account *gtsmodel.Account)
}
// Convert account to ActivityStreams Person.
- person, err := f.tc.AccountToAS(ctx, account)
+ person, err := f.converter.AccountToAS(ctx, account)
if err != nil {
return gtserror.Newf("error converting account to Person: %w", err)
}
// Use ActivityStreams Person as Object of Update.
- update, err := f.tc.WrapPersonInUpdate(person, account)
+ update, err := f.converter.WrapPersonInUpdate(person, account)
if err != nil {
return gtserror.Newf("error wrapping Person in Update: %w", err)
}
@@ -747,7 +747,7 @@ func (f *federate) Block(ctx context.Context, block *gtsmodel.Block) error {
}
// Convert block to ActivityStreams Block.
- asBlock, err := f.tc.BlockToAS(ctx, block)
+ asBlock, err := f.converter.BlockToAS(ctx, block)
if err != nil {
return gtserror.Newf("error converting block to AS: %w", err)
}
@@ -789,7 +789,7 @@ func (f *federate) UndoBlock(ctx context.Context, block *gtsmodel.Block) error {
}
// Convert block to ActivityStreams Block.
- asBlock, err := f.tc.BlockToAS(ctx, block)
+ asBlock, err := f.converter.BlockToAS(ctx, block)
if err != nil {
return gtserror.Newf("error converting block to AS: %w", err)
}
@@ -861,7 +861,7 @@ func (f *federate) Flag(ctx context.Context, report *gtsmodel.Report) error {
}
// Convert report to ActivityStreams Flag.
- flag, err := f.tc.ReportToASFlag(ctx, report)
+ flag, err := f.converter.ReportToASFlag(ctx, report)
if err != nil {
return gtserror.Newf("error converting report to AS: %w", err)
}
diff --git a/internal/processing/workers/fromclientapi.go b/internal/processing/workers/fromclientapi.go
index c48bb7044..1c668db71 100644
--- a/internal/processing/workers/fromclientapi.go
+++ b/internal/processing/workers/fromclientapi.go
@@ -40,7 +40,7 @@ import (
// from the client/REST API.
type clientAPI struct {
state *state.State
- tc typeutils.TypeConverter
+ converter *typeutils.Converter
surface *surface
federate *federate
wipeStatus wipeStatus
@@ -242,7 +242,7 @@ func (p *clientAPI) CreateFollowReq(ctx context.Context, cMsg messages.FromClien
if err := p.federate.Follow(
ctx,
- p.tc.FollowRequestToFollow(ctx, followRequest),
+ p.converter.FollowRequestToFollow(ctx, followRequest),
); err != nil {
return gtserror.Newf("error federating follow: %w", err)
}
@@ -389,7 +389,7 @@ func (p *clientAPI) RejectFollowRequest(ctx context.Context, cMsg messages.FromC
if err := p.federate.RejectFollow(
ctx,
- p.tc.FollowRequestToFollow(ctx, followReq),
+ p.converter.FollowRequestToFollow(ctx, followReq),
); err != nil {
return gtserror.Newf("error federating reject follow: %w", err)
}
diff --git a/internal/processing/workers/surface.go b/internal/processing/workers/surface.go
index a3cf9a3e1..4012dcacc 100644
--- a/internal/processing/workers/surface.go
+++ b/internal/processing/workers/surface.go
@@ -33,7 +33,7 @@ import (
// - sending an email
type surface struct {
state *state.State
- tc typeutils.TypeConverter
+ converter *typeutils.Converter
stream *stream.Processor
filter *visibility.Filter
emailSender email.Sender
diff --git a/internal/processing/workers/surfacenotify.go b/internal/processing/workers/surfacenotify.go
index 00e1205e6..5a4f77a64 100644
--- a/internal/processing/workers/surfacenotify.go
+++ b/internal/processing/workers/surfacenotify.go
@@ -34,7 +34,7 @@ func (s *surface) notifyMentions(
ctx context.Context,
mentions []*gtsmodel.Mention,
) error {
- var errs = gtserror.NewMultiError(len(mentions))
+ errs := gtserror.NewMultiError(len(mentions))
for _, mention := range mentions {
if err := s.notify(
@@ -208,7 +208,7 @@ func (s *surface) notify(
}
// Stream notification to the user.
- apiNotif, err := s.tc.NotificationToAPINotification(ctx, notif)
+ apiNotif, err := s.converter.NotificationToAPINotification(ctx, notif)
if err != nil {
return gtserror.Newf("error converting notification to api representation: %w", err)
}
diff --git a/internal/processing/workers/surfacetimeline.go b/internal/processing/workers/surfacetimeline.go
index 827cbe2f8..a13e6bc70 100644
--- a/internal/processing/workers/surfacetimeline.go
+++ b/internal/processing/workers/surfacetimeline.go
@@ -286,7 +286,6 @@ func (s *surface) listEligible(
list.ID,
status.InReplyToAccountID,
)
-
if err != nil {
err := gtserror.Newf(
"db error checking if account %s in list %s: %w",
@@ -352,7 +351,7 @@ func (s *surface) timelineStatus(
}
// The status was inserted so stream it to the user.
- apiStatus, err := s.tc.StatusToAPIStatus(ctx, status, account)
+ apiStatus, err := s.converter.StatusToAPIStatus(ctx, status, account)
if err != nil {
err = gtserror.Newf("error converting status %s to frontend representation: %w", status.ID, err)
return true, err
diff --git a/internal/processing/workers/workers.go b/internal/processing/workers/workers.go
index 24b18a405..e512a36bf 100644
--- a/internal/processing/workers/workers.go
+++ b/internal/processing/workers/workers.go
@@ -38,7 +38,7 @@ type Processor struct {
func New(
state *state.State,
federator federation.Federator,
- tc typeutils.TypeConverter,
+ converter *typeutils.Converter,
filter *visibility.Filter,
emailSender email.Sender,
account *account.Processor,
@@ -49,7 +49,7 @@ func New(
// wrapper struct.
surface := &surface{
state: state,
- tc: tc,
+ converter: converter,
stream: stream,
filter: filter,
emailSender: emailSender,
@@ -60,7 +60,7 @@ func New(
federate := &federate{
Federator: federator,
state: state,
- tc: tc,
+ converter: converter,
}
// Init shared logic wipe
@@ -75,7 +75,7 @@ func New(
workers: &state.Workers,
clientAPI: &clientAPI{
state: state,
- tc: tc,
+ converter: converter,
surface: surface,
federate: federate,
wipeStatus: wipeStatus,
diff --git a/internal/processing/workers/workers_test.go b/internal/processing/workers/workers_test.go
index 2d5a7f5d3..5a7e645d6 100644
--- a/internal/processing/workers/workers_test.go
+++ b/internal/processing/workers/workers_test.go
@@ -44,7 +44,7 @@ type WorkersTestSuite struct {
storage *storage.Driver
state state.State
mediaManager *media.Manager
- typeconverter typeutils.TypeConverter
+ typeconverter *typeutils.Converter
httpClient *testrig.MockHTTPClient
transportController transport.Controller
federator federation.Federator
@@ -106,7 +106,7 @@ func (suite *WorkersTestSuite) SetupTest() {
suite.testActivities = testrig.NewTestActivities(suite.testAccounts)
suite.storage = testrig.NewInMemoryStorage()
suite.state.Storage = suite.storage
- suite.typeconverter = testrig.NewTestTypeConverter(suite.db)
+ suite.typeconverter = typeutils.NewConverter(&suite.state)
testrig.StartTimelines(
&suite.state,