[chore] deinterface the typeutils.Converter and update to use state structure (#2217)

* update typeconverter to use state structure

* deinterface the typeutils.TypeConverter -> typeutils.Converter

* finish copying over old type converter code comments

* fix cherry-pick merge issues, fix tests pointing to old typeutils interface type still
This commit is contained in:
kim 2023-09-23 17:44:11 +01:00 committed by GitHub
commit 8f67dd583d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
119 changed files with 611 additions and 742 deletions

View file

@ -20,9 +20,10 @@ package testrig
import (
"github.com/superseriousbusiness/gotosocial/internal/federation/federatingdb"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
// NewTestFederatingDB returns a federating DB with the underlying db
func NewTestFederatingDB(state *state.State) federatingdb.DB {
return federatingdb.New(state, NewTestTypeConverter(state.DB))
return federatingdb.New(state, typeutils.NewConverter(state))
}

View file

@ -22,9 +22,10 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/transport"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
// NewTestFederator returns a federator with the given database and (mock!!) transport controller.
func NewTestFederator(state *state.State, tc transport.Controller, mediaManager *media.Manager) federation.Federator {
return federation.NewFederator(state, NewTestFederatingDB(state), tc, NewTestTypeConverter(state.DB), mediaManager)
return federation.NewFederator(state, NewTestFederatingDB(state), tc, typeutils.NewConverter(state), mediaManager)
}

View file

@ -23,11 +23,12 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
// NewTestProcessor returns a Processor suitable for testing purposes
func NewTestProcessor(state *state.State, federator federation.Federator, emailSender email.Sender, mediaManager *media.Manager) *processing.Processor {
p := processing.NewProcessor(NewTestTypeConverter(state.DB), federator, NewTestOauthServer(state.DB), mediaManager, state, emailSender)
p := processing.NewProcessor(typeutils.NewConverter(state), federator, NewTestOauthServer(state.DB), mediaManager, state, emailSender)
state.Workers.EnqueueClientAPI = p.Workers().EnqueueClientAPI
state.Workers.EnqueueFediAPI = p.Workers().EnqueueFediAPI
return p

View file

@ -1,28 +0,0 @@
// GoToSocial
// Copyright (C) GoToSocial Authors admin@gotosocial.org
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package testrig
import (
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
// NewTestTypeConverter returned a type converter with the given db and the default test config
func NewTestTypeConverter(db db.DB) typeutils.TypeConverter {
return typeutils.NewConverter(db)
}

View file

@ -54,11 +54,11 @@ func StopWorkers(state *state.State) {
_ = state.Workers.Media.Stop()
}
func StartTimelines(state *state.State, filter *visibility.Filter, typeConverter typeutils.TypeConverter) {
func StartTimelines(state *state.State, filter *visibility.Filter, converter *typeutils.Converter) {
state.Timelines.Home = timeline.NewManager(
tlprocessor.HomeTimelineGrab(state),
tlprocessor.HomeTimelineFilter(state, filter),
tlprocessor.HomeTimelineStatusPrepare(state, typeConverter),
tlprocessor.HomeTimelineStatusPrepare(state, converter),
tlprocessor.SkipInsert(),
)
if err := state.Timelines.Home.Start(); err != nil {
@ -68,7 +68,7 @@ func StartTimelines(state *state.State, filter *visibility.Filter, typeConverter
state.Timelines.List = timeline.NewManager(
tlprocessor.ListTimelineGrab(state),
tlprocessor.ListTimelineFilter(state, filter),
tlprocessor.ListTimelineStatusPrepare(state, typeConverter),
tlprocessor.ListTimelineStatusPrepare(state, converter),
tlprocessor.SkipInsert(),
)
if err := state.Timelines.List.Start(); err != nil {