mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-10-31 22:40:01 +00: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
|
@ -129,7 +129,7 @@
|
|||
// Build handlers used in later initializations.
|
||||
mediaManager := media.NewManager(&state)
|
||||
oauthServer := oauth.New(ctx, dbService)
|
||||
typeConverter := typeutils.NewConverter(dbService)
|
||||
typeConverter := typeutils.NewConverter(&state)
|
||||
filter := visibility.NewFilter(&state)
|
||||
federatingDB := federatingdb.New(&state, typeConverter)
|
||||
transportController := transport.NewController(&state, federatingDB, &federation.Clock{}, client)
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
"github.com/superseriousbusiness/gotosocial/internal/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/timeline"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/tracing"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/web"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
|
@ -96,7 +97,7 @@
|
|||
federator := testrig.NewTestFederator(&state, transportController, mediaManager)
|
||||
|
||||
emailSender := testrig.NewEmailSender("./web/template/", nil)
|
||||
typeConverter := testrig.NewTestTypeConverter(state.DB)
|
||||
typeConverter := typeutils.NewConverter(&state)
|
||||
filter := visibility.NewFilter(&state)
|
||||
|
||||
// Initialize timelines.
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
type EmojiGetTestSuite struct {
|
||||
suite.Suite
|
||||
db db.DB
|
||||
tc typeutils.TypeConverter
|
||||
tc *typeutils.Converter
|
||||
mediaManager *media.Manager
|
||||
federator federation.Federator
|
||||
emailSender email.Sender
|
||||
|
@ -75,7 +75,7 @@ func (suite *EmojiGetTestSuite) SetupTest() {
|
|||
suite.state.DB = suite.db
|
||||
suite.storage = testrig.NewInMemoryStorage()
|
||||
suite.state.Storage = suite.storage
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
suite.tc = typeutils.NewConverter(&suite.state)
|
||||
|
||||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
|
|
|
@ -39,7 +39,7 @@ type UserStandardTestSuite struct {
|
|||
// standard suite interfaces
|
||||
suite.Suite
|
||||
db db.DB
|
||||
tc typeutils.TypeConverter
|
||||
tc *typeutils.Converter
|
||||
mediaManager *media.Manager
|
||||
federator federation.Federator
|
||||
emailSender email.Sender
|
||||
|
@ -85,7 +85,7 @@ func (suite *UserStandardTestSuite) 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,
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
@ -90,7 +91,7 @@ func (suite *AccountStandardTestSuite) SetupTest() {
|
|||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
visibility.NewFilter(&suite.state),
|
||||
testrig.NewTestTypeConverter(suite.db),
|
||||
typeutils.NewConverter(&suite.state),
|
||||
)
|
||||
|
||||
suite.mediaManager = testrig.NewTestMediaManager(&suite.state)
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
@ -96,7 +97,7 @@ func (suite *AdminStandardTestSuite) SetupTest() {
|
|||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
visibility.NewFilter(&suite.state),
|
||||
testrig.NewTestTypeConverter(suite.db),
|
||||
typeutils.NewConverter(&suite.state),
|
||||
)
|
||||
|
||||
suite.mediaManager = testrig.NewTestMediaManager(&suite.state)
|
||||
|
|
|
@ -50,7 +50,7 @@ type BookmarkTestSuite struct {
|
|||
// standard suite interfaces
|
||||
suite.Suite
|
||||
db db.DB
|
||||
tc typeutils.TypeConverter
|
||||
tc *typeutils.Converter
|
||||
mediaManager *media.Manager
|
||||
federator federation.Federator
|
||||
emailSender email.Sender
|
||||
|
@ -98,7 +98,7 @@ func (suite *BookmarkTestSuite) SetupTest() {
|
|||
suite.storage = testrig.NewInMemoryStorage()
|
||||
suite.state.Storage = suite.storage
|
||||
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
suite.tc = typeutils.NewConverter(&suite.state)
|
||||
|
||||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
|
|
|
@ -37,7 +37,7 @@ type FavouritesStandardTestSuite struct {
|
|||
// standard suite interfaces
|
||||
suite.Suite
|
||||
db db.DB
|
||||
tc typeutils.TypeConverter
|
||||
tc *typeutils.Converter
|
||||
mediaManager *media.Manager
|
||||
federator federation.Federator
|
||||
emailSender email.Sender
|
||||
|
@ -82,7 +82,7 @@ func (suite *FavouritesStandardTestSuite) SetupTest() {
|
|||
suite.storage = testrig.NewInMemoryStorage()
|
||||
suite.state.Storage = suite.storage
|
||||
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
suite.tc = typeutils.NewConverter(&suite.state)
|
||||
|
||||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
@ -87,7 +88,7 @@ func (suite *FollowRequestStandardTestSuite) SetupTest() {
|
|||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
visibility.NewFilter(&suite.state),
|
||||
testrig.NewTestTypeConverter(suite.db),
|
||||
typeutils.NewConverter(&suite.state),
|
||||
)
|
||||
|
||||
suite.mediaManager = testrig.NewTestMediaManager(&suite.state)
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
@ -89,7 +90,7 @@ func (suite *InstanceStandardTestSuite) SetupTest() {
|
|||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
visibility.NewFilter(&suite.state),
|
||||
testrig.NewTestTypeConverter(suite.db),
|
||||
typeutils.NewConverter(&suite.state),
|
||||
)
|
||||
|
||||
suite.mediaManager = testrig.NewTestMediaManager(&suite.state)
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
@ -88,7 +89,7 @@ func (suite *ListsStandardTestSuite) SetupTest() {
|
|||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
visibility.NewFilter(&suite.state),
|
||||
testrig.NewTestTypeConverter(suite.db),
|
||||
typeutils.NewConverter(&suite.state),
|
||||
)
|
||||
|
||||
suite.mediaManager = testrig.NewTestMediaManager(&suite.state)
|
||||
|
|
|
@ -56,7 +56,7 @@ type MediaCreateTestSuite struct {
|
|||
storage *storage.Driver
|
||||
mediaManager *media.Manager
|
||||
federator federation.Federator
|
||||
tc typeutils.TypeConverter
|
||||
tc *typeutils.Converter
|
||||
oauthServer oauth.Server
|
||||
emailSender email.Sender
|
||||
processor *processing.Processor
|
||||
|
@ -91,7 +91,7 @@ func (suite *MediaCreateTestSuite) SetupSuite() {
|
|||
suite.storage = testrig.NewInMemoryStorage()
|
||||
suite.state.Storage = suite.storage
|
||||
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
suite.tc = typeutils.NewConverter(&suite.state)
|
||||
|
||||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
|
|
|
@ -52,7 +52,7 @@ type MediaUpdateTestSuite struct {
|
|||
db db.DB
|
||||
storage *storage.Driver
|
||||
federator federation.Federator
|
||||
tc typeutils.TypeConverter
|
||||
tc *typeutils.Converter
|
||||
mediaManager *media.Manager
|
||||
oauthServer oauth.Server
|
||||
emailSender email.Sender
|
||||
|
@ -87,7 +87,7 @@ func (suite *MediaUpdateTestSuite) SetupSuite() {
|
|||
suite.storage = testrig.NewInMemoryStorage()
|
||||
suite.state.Storage = suite.storage
|
||||
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
suite.tc = typeutils.NewConverter(&suite.state)
|
||||
|
||||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
@ -81,7 +82,7 @@ func (suite *ReportsStandardTestSuite) SetupTest() {
|
|||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
visibility.NewFilter(&suite.state),
|
||||
testrig.NewTestTypeConverter(suite.db),
|
||||
typeutils.NewConverter(&suite.state),
|
||||
)
|
||||
|
||||
suite.mediaManager = testrig.NewTestMediaManager(&suite.state)
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
@ -85,7 +86,7 @@ func (suite *SearchStandardTestSuite) SetupTest() {
|
|||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
visibility.NewFilter(&suite.state),
|
||||
testrig.NewTestTypeConverter(suite.db),
|
||||
typeutils.NewConverter(&suite.state),
|
||||
)
|
||||
|
||||
suite.mediaManager = testrig.NewTestMediaManager(&suite.state)
|
||||
|
|
|
@ -37,7 +37,7 @@ type StatusStandardTestSuite struct {
|
|||
// standard suite interfaces
|
||||
suite.Suite
|
||||
db db.DB
|
||||
tc typeutils.TypeConverter
|
||||
tc *typeutils.Converter
|
||||
mediaManager *media.Manager
|
||||
federator federation.Federator
|
||||
emailSender email.Sender
|
||||
|
@ -82,7 +82,7 @@ func (suite *StatusStandardTestSuite) SetupTest() {
|
|||
suite.storage = testrig.NewInMemoryStorage()
|
||||
suite.state.Storage = suite.storage
|
||||
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
suite.tc = typeutils.NewConverter(&suite.state)
|
||||
|
||||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
|
|
|
@ -49,7 +49,7 @@ type StreamingTestSuite struct {
|
|||
// standard suite interfaces
|
||||
suite.Suite
|
||||
db db.DB
|
||||
tc typeutils.TypeConverter
|
||||
tc *typeutils.Converter
|
||||
mediaManager *media.Manager
|
||||
federator federation.Federator
|
||||
emailSender email.Sender
|
||||
|
@ -94,7 +94,7 @@ func (suite *StreamingTestSuite) SetupTest() {
|
|||
suite.storage = testrig.NewInMemoryStorage()
|
||||
suite.state.Storage = suite.storage
|
||||
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
suite.tc = typeutils.NewConverter(&suite.state)
|
||||
|
||||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
type UserStandardTestSuite struct {
|
||||
suite.Suite
|
||||
db db.DB
|
||||
tc typeutils.TypeConverter
|
||||
tc *typeutils.Converter
|
||||
mediaManager *media.Manager
|
||||
federator federation.Federator
|
||||
emailSender email.Sender
|
||||
|
@ -73,7 +73,7 @@ func (suite *UserStandardTestSuite) SetupTest() {
|
|||
suite.storage = testrig.NewInMemoryStorage()
|
||||
suite.state.Storage = suite.storage
|
||||
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
suite.tc = typeutils.NewConverter(&suite.state)
|
||||
|
||||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
|
|
|
@ -42,7 +42,7 @@ type FileserverTestSuite struct {
|
|||
storage *storage.Driver
|
||||
state state.State
|
||||
federator federation.Federator
|
||||
tc typeutils.TypeConverter
|
||||
tc *typeutils.Converter
|
||||
processor *processing.Processor
|
||||
mediaManager *media.Manager
|
||||
oauthServer oauth.Server
|
||||
|
@ -79,7 +79,7 @@ func (suite *FileserverTestSuite) SetupSuite() {
|
|||
suite.federator = testrig.NewTestFederator(&suite.state, testrig.NewTestTransportController(&suite.state, testrig.NewMockHTTPClient(nil, "../../../testrig/media")), suite.mediaManager)
|
||||
suite.processor = testrig.NewTestProcessor(&suite.state, suite.federator, suite.emailSender, suite.mediaManager)
|
||||
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
suite.tc = typeutils.NewConverter(&suite.state)
|
||||
|
||||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
|
|
|
@ -39,7 +39,7 @@ type WebfingerStandardTestSuite struct {
|
|||
suite.Suite
|
||||
db db.DB
|
||||
state state.State
|
||||
tc typeutils.TypeConverter
|
||||
tc *typeutils.Converter
|
||||
mediaManager *media.Manager
|
||||
federator federation.Federator
|
||||
emailSender email.Sender
|
||||
|
@ -79,7 +79,7 @@ func (suite *WebfingerStandardTestSuite) 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,
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/transport"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
@ -74,7 +75,7 @@ func (suite *MediaTestSuite) SetupTest() {
|
|||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
visibility.NewFilter(&suite.state),
|
||||
testrig.NewTestTypeConverter(suite.db),
|
||||
typeutils.NewConverter(&suite.state),
|
||||
)
|
||||
|
||||
suite.testAttachments = testrig.NewTestAttachments()
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
@ -81,7 +82,8 @@ func (suite *BunDBStandardTestSuite) SetupTest() {
|
|||
testrig.InitTestLog()
|
||||
suite.state.Caches.Init()
|
||||
suite.db = testrig.NewTestDB(&suite.state)
|
||||
testrig.StartTimelines(&suite.state, visibility.NewFilter(&suite.state), testrig.NewTestTypeConverter(suite.db))
|
||||
converter := typeutils.NewConverter(&suite.state)
|
||||
testrig.StartTimelines(&suite.state, visibility.NewFilter(&suite.state), converter)
|
||||
testrig.StandardDBSetup(suite.db, suite.testAccounts)
|
||||
}
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@ func (d *deref) enrichAccount(ctx context.Context, requestUser string, uri *url.
|
|||
}
|
||||
|
||||
// Convert the dereferenced AP account object to our GTS model.
|
||||
latestAcc, err := d.typeConverter.ASRepresentationToAccount(ctx,
|
||||
latestAcc, err := d.converter.ASRepresentationToAccount(ctx,
|
||||
apubAcc,
|
||||
account.Domain,
|
||||
)
|
||||
|
|
|
@ -85,7 +85,7 @@ type Dereferencer interface {
|
|||
|
||||
type deref struct {
|
||||
state *state.State
|
||||
typeConverter typeutils.TypeConverter
|
||||
converter *typeutils.Converter
|
||||
transportController transport.Controller
|
||||
mediaManager *media.Manager
|
||||
derefAvatars map[string]*media.ProcessingMedia
|
||||
|
@ -99,10 +99,10 @@ type deref struct {
|
|||
}
|
||||
|
||||
// NewDereferencer returns a Dereferencer initialized with the given parameters.
|
||||
func NewDereferencer(state *state.State, typeConverter typeutils.TypeConverter, transportController transport.Controller, mediaManager *media.Manager) Dereferencer {
|
||||
func NewDereferencer(state *state.State, converter *typeutils.Converter, transportController transport.Controller, mediaManager *media.Manager) Dereferencer {
|
||||
return &deref{
|
||||
state: state,
|
||||
typeConverter: typeConverter,
|
||||
converter: converter,
|
||||
transportController: transportController,
|
||||
mediaManager: mediaManager,
|
||||
derefAvatars: make(map[string]*media.ProcessingMedia),
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
@ -63,17 +64,19 @@ func (suite *DereferencerStandardTestSuite) SetupTest() {
|
|||
|
||||
suite.db = testrig.NewTestDB(&suite.state)
|
||||
|
||||
converter := typeutils.NewConverter(&suite.state)
|
||||
|
||||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
visibility.NewFilter(&suite.state),
|
||||
testrig.NewTestTypeConverter(suite.db),
|
||||
converter,
|
||||
)
|
||||
|
||||
suite.storage = testrig.NewInMemoryStorage()
|
||||
suite.state.DB = suite.db
|
||||
suite.state.Storage = suite.storage
|
||||
media := testrig.NewTestMediaManager(&suite.state)
|
||||
suite.dereferencer = dereferencing.NewDereferencer(&suite.state, testrig.NewTestTypeConverter(suite.db), testrig.NewTestTransportController(&suite.state, testrig.NewMockHTTPClient(nil, "../../../testrig/media")), media)
|
||||
suite.dereferencer = dereferencing.NewDereferencer(&suite.state, converter, testrig.NewTestTransportController(&suite.state, testrig.NewMockHTTPClient(nil, "../../../testrig/media")), media)
|
||||
testrig.StandardDBSetup(suite.db, nil)
|
||||
}
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ func (d *deref) enrichStatus(
|
|||
|
||||
// ActivityPub model was recently dereferenced, so assume that passed status
|
||||
// may contain out-of-date information, convert AP model to our GTS model.
|
||||
latestStatus, err := d.typeConverter.ASStatusToStatus(ctx, apubStatus)
|
||||
latestStatus, err := d.converter.ASStatusToStatus(ctx, apubStatus)
|
||||
if err != nil {
|
||||
return nil, nil, gtserror.Newf("error converting statusable to gts model for status %s: %w", uri, err)
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
|
|||
return errors.New("ACCEPT: couldn't parse follow into vocab.ActivityStreamsFollow")
|
||||
}
|
||||
// convert the follow to something we can understand
|
||||
gtsFollow, err := f.typeConverter.ASFollowToFollow(ctx, asFollow)
|
||||
gtsFollow, err := f.converter.ASFollowToFollow(ctx, asFollow)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ACCEPT: error converting asfollow to gtsfollow: %s", err)
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ func (f *federatingDB) Announce(ctx context.Context, announce vocab.ActivityStre
|
|||
return nil // Already processed.
|
||||
}
|
||||
|
||||
boost, isNew, err := f.typeConverter.ASAnnounceToStatus(ctx, announce)
|
||||
boost, isNew, err := f.converter.ASAnnounceToStatus(ctx, announce)
|
||||
if err != nil {
|
||||
return gtserror.Newf("error converting announce to boost: %w", err)
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ func (f *federatingDB) activityBlock(ctx context.Context, asType vocab.Type, rec
|
|||
return errors.New("activityBlock: could not convert type to block")
|
||||
}
|
||||
|
||||
block, err := f.typeConverter.ASBlockToBlock(ctx, blockable)
|
||||
block, err := f.converter.ASBlockToBlock(ctx, blockable)
|
||||
if err != nil {
|
||||
return fmt.Errorf("activityBlock: could not convert Block to gts model block")
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ func (f *federatingDB) createStatusable(
|
|||
|
||||
// This is a non-forwarded status we can trust the requester on,
|
||||
// convert this provided statusable data to a useable gtsmodel status.
|
||||
status, err = f.typeConverter.ASStatusToStatus(ctx, statusable)
|
||||
status, err = f.converter.ASStatusToStatus(ctx, statusable)
|
||||
if err != nil {
|
||||
return gtserror.Newf("error converting statusable to status: %w", err)
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ func (f *federatingDB) activityFollow(ctx context.Context, asType vocab.Type, re
|
|||
return errors.New("activityFollow: could not convert type to follow")
|
||||
}
|
||||
|
||||
followRequest, err := f.typeConverter.ASFollowToFollowRequest(ctx, follow)
|
||||
followRequest, err := f.converter.ASFollowToFollowRequest(ctx, follow)
|
||||
if err != nil {
|
||||
return fmt.Errorf("activityFollow: could not convert Follow to follow request: %s", err)
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ func (f *federatingDB) activityLike(ctx context.Context, asType vocab.Type, rece
|
|||
return errors.New("activityLike: could not convert type to like")
|
||||
}
|
||||
|
||||
fave, err := f.typeConverter.ASLikeToFave(ctx, like)
|
||||
fave, err := f.converter.ASLikeToFave(ctx, like)
|
||||
if err != nil {
|
||||
return fmt.Errorf("activityLike: could not convert Like to fave: %w", err)
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ func (f *federatingDB) activityFlag(ctx context.Context, asType vocab.Type, rece
|
|||
return errors.New("activityFlag: could not convert type to flag")
|
||||
}
|
||||
|
||||
report, err := f.typeConverter.ASFlagToReport(ctx, flag)
|
||||
report, err := f.converter.ASFlagToReport(ctx, flag)
|
||||
if err != nil {
|
||||
return fmt.Errorf("activityFlag: could not convert Flag to report: %w", err)
|
||||
}
|
||||
|
|
|
@ -39,17 +39,17 @@ type DB interface {
|
|||
// FederatingDB uses the underlying DB interface to implement the go-fed pub.Database interface.
|
||||
// It doesn't care what the underlying implementation of the DB interface is, as long as it works.
|
||||
type federatingDB struct {
|
||||
locks mutexes.MutexMap
|
||||
state *state.State
|
||||
typeConverter typeutils.TypeConverter
|
||||
locks mutexes.MutexMap
|
||||
state *state.State
|
||||
converter *typeutils.Converter
|
||||
}
|
||||
|
||||
// New returns a DB interface using the given database and config
|
||||
func New(state *state.State, tc typeutils.TypeConverter) DB {
|
||||
func New(state *state.State, converter *typeutils.Converter) DB {
|
||||
fdb := federatingDB{
|
||||
locks: mutexes.NewMap(-1, -1), // use defaults
|
||||
state: state,
|
||||
typeConverter: tc,
|
||||
locks: mutexes.NewMap(-1, -1), // use defaults
|
||||
state: state,
|
||||
converter: converter,
|
||||
}
|
||||
return &fdb
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
type FederatingDBTestSuite struct {
|
||||
suite.Suite
|
||||
db db.DB
|
||||
tc typeutils.TypeConverter
|
||||
tc *typeutils.Converter
|
||||
fromFederator chan messages.FromFediAPI
|
||||
federatingDB federatingdb.DB
|
||||
state state.State
|
||||
|
@ -79,7 +79,7 @@ func (suite *FederatingDBTestSuite) SetupTest() {
|
|||
suite.db = testrig.NewTestDB(&suite.state)
|
||||
|
||||
suite.testActivities = testrig.NewTestActivities(suite.testAccounts)
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
suite.tc = typeutils.NewConverter(&suite.state)
|
||||
|
||||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
|
|
|
@ -42,13 +42,13 @@ func (f *federatingDB) Get(ctx context.Context, id *url.URL) (value vocab.Type,
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return f.typeConverter.AccountToAS(ctx, acct)
|
||||
return f.converter.AccountToAS(ctx, acct)
|
||||
case uris.IsStatusesPath(id):
|
||||
status, err := f.state.DB.GetStatusByURI(ctx, id.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return f.typeConverter.StatusToAS(ctx, status)
|
||||
return f.converter.StatusToAS(ctx, status)
|
||||
case uris.IsFollowersPath(id):
|
||||
return f.Followers(ctx, id)
|
||||
case uris.IsFollowingPath(id):
|
||||
|
|
|
@ -85,7 +85,7 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR
|
|||
}
|
||||
|
||||
// convert the follow to something we can understand
|
||||
gtsFollow, err := f.typeConverter.ASFollowToFollow(ctx, asFollow)
|
||||
gtsFollow, err := f.converter.ASFollowToFollow(ctx, asFollow)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Reject: error converting asfollow to gtsfollow: %s", err)
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ func (f *federatingDB) undoFollow(
|
|||
return nil
|
||||
}
|
||||
|
||||
follow, err := f.typeConverter.ASFollowToFollow(ctx, Follow)
|
||||
follow, err := f.converter.ASFollowToFollow(ctx, Follow)
|
||||
if err != nil {
|
||||
return fmt.Errorf("undoFollow: error converting ActivityStreams Follow to follow: %w", err)
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ func (f *federatingDB) undoLike(
|
|||
return nil
|
||||
}
|
||||
|
||||
fave, err := f.typeConverter.ASLikeToFave(ctx, Like)
|
||||
fave, err := f.converter.ASLikeToFave(ctx, Like)
|
||||
if err != nil {
|
||||
return fmt.Errorf("undoLike: error converting ActivityStreams Like to fave: %w", err)
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ func (f *federatingDB) undoBlock(
|
|||
return nil
|
||||
}
|
||||
|
||||
block, err := f.typeConverter.ASBlockToBlock(ctx, Block)
|
||||
block, err := f.converter.ASBlockToBlock(ctx, Block)
|
||||
if err != nil {
|
||||
return fmt.Errorf("undoBlock: error converting ActivityStreams Block to block: %w", err)
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ type federator struct {
|
|||
db db.DB
|
||||
federatingDB federatingdb.DB
|
||||
clock pub.Clock
|
||||
typeConverter typeutils.TypeConverter
|
||||
converter *typeutils.Converter
|
||||
transportController transport.Controller
|
||||
mediaManager *media.Manager
|
||||
actor pub.FederatingActor
|
||||
|
@ -67,15 +67,15 @@ type federator struct {
|
|||
}
|
||||
|
||||
// NewFederator returns a new federator
|
||||
func NewFederator(state *state.State, federatingDB federatingdb.DB, transportController transport.Controller, typeConverter typeutils.TypeConverter, mediaManager *media.Manager) Federator {
|
||||
dereferencer := dereferencing.NewDereferencer(state, typeConverter, transportController, mediaManager)
|
||||
func NewFederator(state *state.State, federatingDB federatingdb.DB, transportController transport.Controller, converter *typeutils.Converter, mediaManager *media.Manager) Federator {
|
||||
dereferencer := dereferencing.NewDereferencer(state, converter, transportController, mediaManager)
|
||||
|
||||
clock := &Clock{}
|
||||
f := &federator{
|
||||
db: state.DB,
|
||||
federatingDB: federatingDB,
|
||||
clock: &Clock{},
|
||||
typeConverter: typeConverter,
|
||||
converter: converter,
|
||||
transportController: transportController,
|
||||
mediaManager: mediaManager,
|
||||
Dereferencer: dereferencer,
|
||||
|
|
|
@ -36,7 +36,7 @@ type FederatorStandardTestSuite struct {
|
|||
suite.Suite
|
||||
storage *storage.Driver
|
||||
state state.State
|
||||
typeconverter typeutils.TypeConverter
|
||||
typeconverter *typeutils.Converter
|
||||
transportController transport.Controller
|
||||
httpClient *testrig.MockHTTPClient
|
||||
federator federation.Federator
|
||||
|
@ -65,7 +65,7 @@ func (suite *FederatorStandardTestSuite) SetupTest() {
|
|||
suite.testActivities = testrig.NewTestActivities(suite.testAccounts)
|
||||
suite.storage = testrig.NewInMemoryStorage()
|
||||
suite.state.Storage = suite.storage
|
||||
suite.typeconverter = testrig.NewTestTypeConverter(suite.state.DB)
|
||||
suite.typeconverter = typeutils.NewConverter(&suite.state)
|
||||
|
||||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/transport"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
@ -60,7 +61,7 @@ func (suite *MediaStandardTestSuite) SetupTest() {
|
|||
testrig.StartTimelines(
|
||||
&suite.state,
|
||||
visibility.NewFilter(&suite.state),
|
||||
testrig.NewTestTypeConverter(suite.db),
|
||||
typeutils.NewConverter(&suite.state),
|
||||
)
|
||||
|
||||
suite.testAttachments = testrig.NewTestAttachments()
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
// 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 {
|
||||
|
|
|
@ -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 @@
|
|||
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)
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
)
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
)
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -26,16 +26,16 @@
|
|||
|
||||
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,
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
// 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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
)
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,16 +27,16 @@
|
|||
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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
)
|
||||
|
||||
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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -29,18 +29,18 @@
|
|||
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,
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
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))
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
"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{
|
||||
|
|
|
@ -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 @@
|
|||
)
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
// 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)
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
// - sending an email
|
||||
type surface struct {
|
||||
state *state.State
|
||||
tc typeutils.TypeConverter
|
||||
converter *typeutils.Converter
|
||||
stream *stream.Processor
|
||||
filter *visibility.Filter
|
||||
emailSender email.Sender
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue