[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
This commit is contained in:
kim 2023-09-23 17:44:11 +01:00 committed by GitHub
commit 8f67dd583d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
119 changed files with 611 additions and 742 deletions

View file

@ -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

View file

@ -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,
}
}

View file

@ -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))
}