diff options
author | 2023-09-23 17:44:11 +0100 | |
---|---|---|
committer | 2023-09-23 18:44:11 +0200 | |
commit | 8f67dd583d86155440e7905ae23083a9fea42f72 (patch) | |
tree | e67abf09a53c2d9053df8072b074a026969d93ef /internal/processing/account | |
parent | [chore] fix typo in slice.go (#2219) (diff) | |
download | gotosocial-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/account')
-rw-r--r-- | internal/processing/account/account.go | 6 | ||||
-rw-r--r-- | internal/processing/account/account_test.go | 4 | ||||
-rw-r--r-- | internal/processing/account/block.go | 2 | ||||
-rw-r--r-- | internal/processing/account/bookmarks.go | 2 | ||||
-rw-r--r-- | internal/processing/account/get.go | 6 | ||||
-rw-r--r-- | internal/processing/account/lists.go | 2 | ||||
-rw-r--r-- | internal/processing/account/relationships.go | 2 | ||||
-rw-r--r-- | internal/processing/account/rss.go | 2 | ||||
-rw-r--r-- | internal/processing/account/statuses.go | 4 | ||||
-rw-r--r-- | internal/processing/account/update.go | 2 |
10 files changed, 16 insertions, 16 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)) } |