diff options
Diffstat (limited to 'internal/cliactions')
-rw-r--r-- | internal/cliactions/action.go | 3 | ||||
-rw-r--r-- | internal/cliactions/admin/account/account.go | 27 | ||||
-rw-r--r-- | internal/cliactions/admin/trans/export.go | 7 | ||||
-rw-r--r-- | internal/cliactions/admin/trans/import.go | 7 | ||||
-rw-r--r-- | internal/cliactions/server/server.go | 74 | ||||
-rw-r--r-- | internal/cliactions/testrig/testrig.go | 54 |
6 files changed, 84 insertions, 88 deletions
diff --git a/internal/cliactions/action.go b/internal/cliactions/action.go index 3ba91de8d..b72ae92b8 100644 --- a/internal/cliactions/action.go +++ b/internal/cliactions/action.go @@ -21,11 +21,10 @@ package cliactions import ( "context" - "github.com/sirupsen/logrus" "github.com/superseriousbusiness/gotosocial/internal/config" ) // GTSAction defines one *action* that can be taken by the gotosocial cli command. // This can be either a long-running action (like server start) or something // shorter like db init or db inspect. -type GTSAction func(context.Context, *config.Config, *logrus.Logger) error +type GTSAction func(context.Context, *config.Config) error diff --git a/internal/cliactions/admin/account/account.go b/internal/cliactions/admin/account/account.go index e9a113f35..5bdee9a41 100644 --- a/internal/cliactions/admin/account/account.go +++ b/internal/cliactions/admin/account/account.go @@ -24,7 +24,6 @@ import ( "fmt" "time" - "github.com/sirupsen/logrus" "github.com/superseriousbusiness/gotosocial/internal/cliactions" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" @@ -35,8 +34,8 @@ import ( ) // Create creates a new account in the database using the provided flags. -var Create cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { - dbConn, err := bundb.NewBunDBService(ctx, c, log) +var Create cliactions.GTSAction = func(ctx context.Context, c *config.Config) error { + dbConn, err := bundb.NewBunDBService(ctx, c) if err != nil { return fmt.Errorf("error creating dbservice: %s", err) } @@ -74,8 +73,8 @@ var Create cliactions.GTSAction = func(ctx context.Context, c *config.Config, lo } // Confirm sets a user to Approved, sets Email to the current UnconfirmedEmail value, and sets ConfirmedAt to now. -var Confirm cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { - dbConn, err := bundb.NewBunDBService(ctx, c, log) +var Confirm cliactions.GTSAction = func(ctx context.Context, c *config.Config) error { + dbConn, err := bundb.NewBunDBService(ctx, c) if err != nil { return fmt.Errorf("error creating dbservice: %s", err) } @@ -109,8 +108,8 @@ var Confirm cliactions.GTSAction = func(ctx context.Context, c *config.Config, l } // Promote sets a user to admin. -var Promote cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { - dbConn, err := bundb.NewBunDBService(ctx, c, log) +var Promote cliactions.GTSAction = func(ctx context.Context, c *config.Config) error { + dbConn, err := bundb.NewBunDBService(ctx, c) if err != nil { return fmt.Errorf("error creating dbservice: %s", err) } @@ -141,8 +140,8 @@ var Promote cliactions.GTSAction = func(ctx context.Context, c *config.Config, l } // Demote sets admin on a user to false. -var Demote cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { - dbConn, err := bundb.NewBunDBService(ctx, c, log) +var Demote cliactions.GTSAction = func(ctx context.Context, c *config.Config) error { + dbConn, err := bundb.NewBunDBService(ctx, c) if err != nil { return fmt.Errorf("error creating dbservice: %s", err) } @@ -173,8 +172,8 @@ var Demote cliactions.GTSAction = func(ctx context.Context, c *config.Config, lo } // Disable sets Disabled to true on a user. -var Disable cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { - dbConn, err := bundb.NewBunDBService(ctx, c, log) +var Disable cliactions.GTSAction = func(ctx context.Context, c *config.Config) error { + dbConn, err := bundb.NewBunDBService(ctx, c) if err != nil { return fmt.Errorf("error creating dbservice: %s", err) } @@ -205,14 +204,14 @@ var Disable cliactions.GTSAction = func(ctx context.Context, c *config.Config, l } // Suspend suspends the target account, cleanly removing all of its media, followers, following, likes, statuses, etc. -var Suspend cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { +var Suspend cliactions.GTSAction = func(ctx context.Context, c *config.Config) error { // TODO return nil } // Password sets the password of target account. -var Password cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { - dbConn, err := bundb.NewBunDBService(ctx, c, log) +var Password cliactions.GTSAction = func(ctx context.Context, c *config.Config) error { + dbConn, err := bundb.NewBunDBService(ctx, c) if err != nil { return fmt.Errorf("error creating dbservice: %s", err) } diff --git a/internal/cliactions/admin/trans/export.go b/internal/cliactions/admin/trans/export.go index 3d9607ea6..89a22a357 100644 --- a/internal/cliactions/admin/trans/export.go +++ b/internal/cliactions/admin/trans/export.go @@ -23,7 +23,6 @@ import ( "errors" "fmt" - "github.com/sirupsen/logrus" "github.com/superseriousbusiness/gotosocial/internal/cliactions" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db/bundb" @@ -31,13 +30,13 @@ import ( ) // Export exports info from the database into a file -var Export cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { - dbConn, err := bundb.NewBunDBService(ctx, c, log) +var Export cliactions.GTSAction = func(ctx context.Context, c *config.Config) error { + dbConn, err := bundb.NewBunDBService(ctx, c) if err != nil { return fmt.Errorf("error creating dbservice: %s", err) } - exporter := trans.NewExporter(dbConn, log) + exporter := trans.NewExporter(dbConn) path, ok := c.ExportCLIFlags[config.TransPathFlag] if !ok { diff --git a/internal/cliactions/admin/trans/import.go b/internal/cliactions/admin/trans/import.go index 7b137eccc..82defde74 100644 --- a/internal/cliactions/admin/trans/import.go +++ b/internal/cliactions/admin/trans/import.go @@ -23,7 +23,6 @@ import ( "errors" "fmt" - "github.com/sirupsen/logrus" "github.com/superseriousbusiness/gotosocial/internal/cliactions" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db/bundb" @@ -31,13 +30,13 @@ import ( ) // Import imports info from a file into the database -var Import cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { - dbConn, err := bundb.NewBunDBService(ctx, c, log) +var Import cliactions.GTSAction = func(ctx context.Context, c *config.Config) error { + dbConn, err := bundb.NewBunDBService(ctx, c) if err != nil { return fmt.Errorf("error creating dbservice: %s", err) } - importer := trans.NewImporter(dbConn, log) + importer := trans.NewImporter(dbConn) path, ok := c.ExportCLIFlags[config.TransPathFlag] if !ok { diff --git a/internal/cliactions/server/server.go b/internal/cliactions/server/server.go index e75eff7c5..107d84d2c 100644 --- a/internal/cliactions/server/server.go +++ b/internal/cliactions/server/server.go @@ -51,8 +51,8 @@ import ( ) // Start creates and starts a gotosocial server -var Start cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { - dbService, err := bundb.NewBunDBService(ctx, c, log) +var Start cliactions.GTSAction = func(ctx context.Context, c *config.Config) error { + dbService, err := bundb.NewBunDBService(ctx, c) if err != nil { return fmt.Errorf("error creating dbservice: %s", err) } @@ -69,9 +69,9 @@ var Start cliactions.GTSAction = func(ctx context.Context, c *config.Config, log return fmt.Errorf("error creating instance instance: %s", err) } - federatingDB := federatingdb.New(dbService, c, log) + federatingDB := federatingdb.New(dbService, c) - router, err := router.New(ctx, c, dbService, log) + router, err := router.New(ctx, c, dbService) if err != nil { return fmt.Errorf("error creating router: %s", err) } @@ -83,48 +83,48 @@ var Start cliactions.GTSAction = func(ctx context.Context, c *config.Config, log } // build converters and util - typeConverter := typeutils.NewConverter(c, dbService, log) - timelineManager := timelineprocessing.NewManager(dbService, typeConverter, c, log) + typeConverter := typeutils.NewConverter(c, dbService) + timelineManager := timelineprocessing.NewManager(dbService, typeConverter, c) // build backend handlers - mediaHandler := media.New(c, dbService, storage, log) - oauthServer := oauth.New(ctx, dbService, log) - transportController := transport.NewController(c, dbService, &federation.Clock{}, http.DefaultClient, log) - federator := federation.NewFederator(dbService, federatingDB, transportController, c, log, typeConverter, mediaHandler) - processor := processing.NewProcessor(c, typeConverter, federator, oauthServer, mediaHandler, storage, timelineManager, dbService, log) + mediaHandler := media.New(c, dbService, storage) + oauthServer := oauth.New(ctx, dbService) + transportController := transport.NewController(c, dbService, &federation.Clock{}, http.DefaultClient) + federator := federation.NewFederator(dbService, federatingDB, transportController, c, typeConverter, mediaHandler) + processor := processing.NewProcessor(c, typeConverter, federator, oauthServer, mediaHandler, storage, timelineManager, dbService) if err := processor.Start(ctx); err != nil { return fmt.Errorf("error starting processor: %s", err) } - idp, err := oidc.NewIDP(ctx, c, log) + idp, err := oidc.NewIDP(ctx, c) if err != nil { return fmt.Errorf("error creating oidc idp: %s", err) } // build client api modules - authModule := auth.New(c, dbService, oauthServer, idp, log) - accountModule := account.New(c, processor, log) - instanceModule := instance.New(c, processor, log) - appsModule := app.New(c, processor, log) - followRequestsModule := followrequest.New(c, processor, log) - webfingerModule := webfinger.New(c, processor, log) - nodeInfoModule := nodeinfo.New(c, processor, log) - webBaseModule := web.New(c, processor, log) - usersModule := user.New(c, processor, log) - timelineModule := timeline.New(c, processor, log) - notificationModule := notification.New(c, processor, log) - searchModule := search.New(c, processor, log) - filtersModule := filter.New(c, processor, log) - emojiModule := emoji.New(c, processor, log) - listsModule := list.New(c, processor, log) - mm := mediaModule.New(c, processor, log) - fileServerModule := fileserver.New(c, processor, log) - adminModule := admin.New(c, processor, log) - statusModule := status.New(c, processor, log) - securityModule := security.New(c, dbService, log) - streamingModule := streaming.New(c, processor, log) - favouritesModule := favourites.New(c, processor, log) - blocksModule := blocks.New(c, processor, log) + authModule := auth.New(c, dbService, oauthServer, idp) + accountModule := account.New(c, processor) + instanceModule := instance.New(c, processor) + appsModule := app.New(c, processor) + followRequestsModule := followrequest.New(c, processor) + webfingerModule := webfinger.New(c, processor) + nodeInfoModule := nodeinfo.New(c, processor) + webBaseModule := web.New(c, processor) + usersModule := user.New(c, processor) + timelineModule := timeline.New(c, processor) + notificationModule := notification.New(c, processor) + searchModule := search.New(c, processor) + filtersModule := filter.New(c, processor) + emojiModule := emoji.New(c, processor) + listsModule := list.New(c, processor) + mm := mediaModule.New(c, processor) + fileServerModule := fileserver.New(c, processor) + adminModule := admin.New(c, processor) + statusModule := status.New(c, processor) + securityModule := security.New(c, dbService) + streamingModule := streaming.New(c, processor) + favouritesModule := favourites.New(c, processor) + blocksModule := blocks.New(c, processor) apis := []api.ClientModule{ // modules with middleware go first @@ -174,13 +174,13 @@ var Start cliactions.GTSAction = func(ctx context.Context, c *config.Config, log sigs := make(chan os.Signal, 1) signal.Notify(sigs, os.Interrupt, syscall.SIGTERM) sig := <-sigs - log.Infof("received signal %s, shutting down", sig) + logrus.Infof("received signal %s, shutting down", sig) // close down all running services in order if err := gts.Stop(ctx); err != nil { return fmt.Errorf("error closing gotosocial service: %s", err) } - log.Info("done! exiting...") + logrus.Info("done! exiting...") return nil } diff --git a/internal/cliactions/testrig/testrig.go b/internal/cliactions/testrig/testrig.go index 482ec34f8..2993d8613 100644 --- a/internal/cliactions/testrig/testrig.go +++ b/internal/cliactions/testrig/testrig.go @@ -43,7 +43,7 @@ import ( ) // Start creates and starts a gotosocial testrig server -var Start cliactions.GTSAction = func(ctx context.Context, _ *config.Config, log *logrus.Logger) error { +var Start cliactions.GTSAction = func(ctx context.Context, _ *config.Config) error { c := testrig.NewTestConfig() dbService := testrig.NewTestDB() testrig.StandardDBSetup(dbService, nil) @@ -67,35 +67,35 @@ var Start cliactions.GTSAction = func(ctx context.Context, _ *config.Config, log return fmt.Errorf("error starting processor: %s", err) } - idp, err := oidc.NewIDP(ctx, c, log) + idp, err := oidc.NewIDP(ctx, c) if err != nil { return fmt.Errorf("error creating oidc idp: %s", err) } // build client api modules - authModule := auth.New(c, dbService, oauthServer, idp, log) - accountModule := account.New(c, processor, log) - instanceModule := instance.New(c, processor, log) - appsModule := app.New(c, processor, log) - followRequestsModule := followrequest.New(c, processor, log) - webfingerModule := webfinger.New(c, processor, log) - nodeInfoModule := nodeinfo.New(c, processor, log) - webBaseModule := web.New(c, processor, log) - usersModule := user.New(c, processor, log) - timelineModule := timeline.New(c, processor, log) - notificationModule := notification.New(c, processor, log) - searchModule := search.New(c, processor, log) - filtersModule := filter.New(c, processor, log) - emojiModule := emoji.New(c, processor, log) - listsModule := list.New(c, processor, log) - mm := mediaModule.New(c, processor, log) - fileServerModule := fileserver.New(c, processor, log) - adminModule := admin.New(c, processor, log) - statusModule := status.New(c, processor, log) - securityModule := security.New(c, dbService, log) - streamingModule := streaming.New(c, processor, log) - favouritesModule := favourites.New(c, processor, log) - blocksModule := blocks.New(c, processor, log) + authModule := auth.New(c, dbService, oauthServer, idp) + accountModule := account.New(c, processor) + instanceModule := instance.New(c, processor) + appsModule := app.New(c, processor) + followRequestsModule := followrequest.New(c, processor) + webfingerModule := webfinger.New(c, processor) + nodeInfoModule := nodeinfo.New(c, processor) + webBaseModule := web.New(c, processor) + usersModule := user.New(c, processor) + timelineModule := timeline.New(c, processor) + notificationModule := notification.New(c, processor) + searchModule := search.New(c, processor) + filtersModule := filter.New(c, processor) + emojiModule := emoji.New(c, processor) + listsModule := list.New(c, processor) + mm := mediaModule.New(c, processor) + fileServerModule := fileserver.New(c, processor) + adminModule := admin.New(c, processor) + statusModule := status.New(c, processor) + securityModule := security.New(c, dbService) + streamingModule := streaming.New(c, processor) + favouritesModule := favourites.New(c, processor) + blocksModule := blocks.New(c, processor) apis := []api.ClientModule{ // modules with middleware go first @@ -145,7 +145,7 @@ var Start cliactions.GTSAction = func(ctx context.Context, _ *config.Config, log sigs := make(chan os.Signal, 1) signal.Notify(sigs, os.Interrupt, syscall.SIGTERM) sig := <-sigs - log.Infof("received signal %s, shutting down", sig) + logrus.Infof("received signal %s, shutting down", sig) testrig.StandardDBTeardown(dbService) testrig.StandardStorageTeardown(storageBackend) @@ -155,6 +155,6 @@ var Start cliactions.GTSAction = func(ctx context.Context, _ *config.Config, log return fmt.Errorf("error closing gotosocial service: %s", err) } - log.Info("done! exiting...") + logrus.Info("done! exiting...") return nil } |