mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 14:52:26 -05: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
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue