diff options
author | 2023-05-25 10:37:38 +0200 | |
---|---|---|
committer | 2023-05-25 10:37:38 +0200 | |
commit | f5c004d67d4ed66b6c6df100afec47174aa14ae0 (patch) | |
tree | 45b72a6e90450d711e10571d844138186fe023c9 /cmd | |
parent | [docs] local docs hacking howto (#1816) (diff) | |
download | gotosocial-f5c004d67d4ed66b6c6df100afec47174aa14ae0.tar.xz |
[feature] Add List functionality (#1802)
* start working on lists
* further list work
* test list db functions nicely
* more work on lists
* peepoopeepoo
* poke
* start list timeline func
* we're getting there lads
* couldn't be me working on stuff... could it?
* hook up handlers
* fiddling
* weeee
* woah
* screaming, pissing
* fix streaming being a whiny baby
* lint, small test fix, swagger
* tidying up, testing
* fucked! by the linter
* move timelines to state like a boss
* add timeline start to tests using state
* invalidate lists
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gotosocial/action/server/server.go | 40 | ||||
-rw-r--r-- | cmd/gotosocial/action/testrig/testrig.go | 29 |
2 files changed, 57 insertions, 12 deletions
diff --git a/cmd/gotosocial/action/server/server.go b/cmd/gotosocial/action/server/server.go index 76e58c2f8..fa4ec9b82 100644 --- a/cmd/gotosocial/action/server/server.go +++ b/cmd/gotosocial/action/server/server.go @@ -32,7 +32,10 @@ import ( apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util" "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/middleware" + tlprocessor "github.com/superseriousbusiness/gotosocial/internal/processing/timeline" + "github.com/superseriousbusiness/gotosocial/internal/timeline" "github.com/superseriousbusiness/gotosocial/internal/tracing" + "github.com/superseriousbusiness/gotosocial/internal/visibility" "go.uber.org/automaxprocs/maxprocs" "github.com/superseriousbusiness/gotosocial/internal/config" @@ -72,7 +75,6 @@ var Start action.GTSAction = func(ctx context.Context) error { defer state.Caches.Stop() // Initialize Tracing - if err := tracing.Initialize(); err != nil { return fmt.Errorf("error initializing tracing: %w", err) } @@ -110,36 +112,56 @@ var Start action.GTSAction = func(ctx context.Context) error { state.Workers.Start() defer state.Workers.Stop() - // build backend handlers + // Build handlers used in later initializations. mediaManager := media.NewManager(&state) oauthServer := oauth.New(ctx, dbService) typeConverter := typeutils.NewConverter(dbService) + filter := visibility.NewFilter(&state) federatingDB := federatingdb.New(&state, typeConverter) transportController := transport.NewController(&state, federatingDB, &federation.Clock{}, client) federator := federation.NewFederator(&state, federatingDB, transportController, typeConverter, mediaManager) - // decide whether to create a noop email sender (won't send emails) or a real one + // Decide whether to create a noop email + // sender (won't send emails) or a real one. var emailSender email.Sender if smtpHost := config.GetSMTPHost(); smtpHost != "" { - // host is defined so create a proper sender + // Host is defined; create a proper sender. emailSender, err = email.NewSender() if err != nil { return fmt.Errorf("error creating email sender: %s", err) } } else { - // no host is defined so create a noop sender + // No host is defined; create a noop sender. emailSender, err = email.NewNoopSender(nil) if err != nil { return fmt.Errorf("error creating noop email sender: %s", err) } } - // create the message processor using the other services we've created so far - processor := processing.NewProcessor(typeConverter, federator, oauthServer, mediaManager, &state, emailSender) - if err := processor.Start(); err != nil { - return fmt.Errorf("error creating processor: %s", err) + // Initialize timelines. + state.Timelines.Home = timeline.NewManager( + tlprocessor.HomeTimelineGrab(&state), + tlprocessor.HomeTimelineFilter(&state, filter), + tlprocessor.HomeTimelineStatusPrepare(&state, typeConverter), + tlprocessor.SkipInsert(), + ) + if err := state.Timelines.Home.Start(); err != nil { + return fmt.Errorf("error starting home timeline: %s", err) + } + + state.Timelines.List = timeline.NewManager( + tlprocessor.ListTimelineGrab(&state), + tlprocessor.ListTimelineFilter(&state, filter), + tlprocessor.ListTimelineStatusPrepare(&state, typeConverter), + tlprocessor.SkipInsert(), + ) + if err := state.Timelines.List.Start(); err != nil { + return fmt.Errorf("error starting list timeline: %s", err) } + // Create the processor using all the other services we've created so far. + processor := processing.NewProcessor(typeConverter, federator, oauthServer, mediaManager, &state, emailSender) + // Set state client / federator worker enqueue functions state.Workers.EnqueueClientAPI = processor.EnqueueClientAPI state.Workers.EnqueueFederator = processor.EnqueueFederator diff --git a/cmd/gotosocial/action/testrig/testrig.go b/cmd/gotosocial/action/testrig/testrig.go index 5d4f20773..8f55c4b4a 100644 --- a/cmd/gotosocial/action/testrig/testrig.go +++ b/cmd/gotosocial/action/testrig/testrig.go @@ -38,9 +38,12 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/log" "github.com/superseriousbusiness/gotosocial/internal/middleware" "github.com/superseriousbusiness/gotosocial/internal/oidc" + tlprocessor "github.com/superseriousbusiness/gotosocial/internal/processing/timeline" "github.com/superseriousbusiness/gotosocial/internal/state" "github.com/superseriousbusiness/gotosocial/internal/storage" + "github.com/superseriousbusiness/gotosocial/internal/timeline" "github.com/superseriousbusiness/gotosocial/internal/tracing" + "github.com/superseriousbusiness/gotosocial/internal/visibility" "github.com/superseriousbusiness/gotosocial/internal/web" "github.com/superseriousbusiness/gotosocial/testrig" ) @@ -89,12 +92,32 @@ var Start action.GTSAction = func(ctx context.Context) error { federator := testrig.NewTestFederator(&state, transportController, mediaManager) emailSender := testrig.NewEmailSender("./web/template/", nil) + typeConverter := testrig.NewTestTypeConverter(state.DB) + filter := visibility.NewFilter(&state) + + // Initialize timelines. + state.Timelines.Home = timeline.NewManager( + tlprocessor.HomeTimelineGrab(&state), + tlprocessor.HomeTimelineFilter(&state, filter), + tlprocessor.HomeTimelineStatusPrepare(&state, typeConverter), + tlprocessor.SkipInsert(), + ) + if err := state.Timelines.Home.Start(); err != nil { + return fmt.Errorf("error starting home timeline: %s", err) + } - processor := testrig.NewTestProcessor(&state, federator, emailSender, mediaManager) - if err := processor.Start(); err != nil { - return fmt.Errorf("error starting processor: %s", err) + state.Timelines.List = timeline.NewManager( + tlprocessor.ListTimelineGrab(&state), + tlprocessor.ListTimelineFilter(&state, filter), + tlprocessor.ListTimelineStatusPrepare(&state, typeConverter), + tlprocessor.SkipInsert(), + ) + if err := state.Timelines.List.Start(); err != nil { + return fmt.Errorf("error starting list timeline: %s", err) } + processor := testrig.NewTestProcessor(&state, federator, emailSender, mediaManager) + /* HTTP router initialization */ |