mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-28 07:33:32 -06:00
[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:
parent
1b848aa1e5
commit
8f67dd583d
119 changed files with 611 additions and 742 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue