summaryrefslogtreecommitdiff
path: root/cmd/gotosocial/action/admin/account/account.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/gotosocial/action/admin/account/account.go')
-rw-r--r--cmd/gotosocial/action/admin/account/account.go49
1 files changed, 43 insertions, 6 deletions
diff --git a/cmd/gotosocial/action/admin/account/account.go b/cmd/gotosocial/action/admin/account/account.go
index 35c2f68ab..5cde9bdf3 100644
--- a/cmd/gotosocial/action/admin/account/account.go
+++ b/cmd/gotosocial/action/admin/account/account.go
@@ -27,17 +27,24 @@ import (
"github.com/superseriousbusiness/gotosocial/cmd/gotosocial/action"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db/bundb"
+ "github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/validate"
"golang.org/x/crypto/bcrypt"
)
// Create creates a new account in the database using the provided flags.
var Create action.GTSAction = func(ctx context.Context) error {
- dbConn, err := bundb.NewBunDBService(ctx)
+ var state state.State
+ state.Caches.Init()
+
+ dbConn, err := bundb.NewBunDBService(ctx, &state)
if err != nil {
return fmt.Errorf("error creating dbservice: %s", err)
}
+ // Set the state DB connection
+ state.DB = dbConn
+
username := config.GetAdminAccountUsername()
if username == "" {
return errors.New("no username set")
@@ -88,11 +95,17 @@ var Create action.GTSAction = func(ctx context.Context) error {
// Confirm sets a user to Approved, sets Email to the current UnconfirmedEmail value, and sets ConfirmedAt to now.
var Confirm action.GTSAction = func(ctx context.Context) error {
- dbConn, err := bundb.NewBunDBService(ctx)
+ var state state.State
+ state.Caches.Init()
+
+ dbConn, err := bundb.NewBunDBService(ctx, &state)
if err != nil {
return fmt.Errorf("error creating dbservice: %s", err)
}
+ // Set the state DB connection
+ state.DB = dbConn
+
username := config.GetAdminAccountUsername()
if username == "" {
return errors.New("no username set")
@@ -125,11 +138,17 @@ var Confirm action.GTSAction = func(ctx context.Context) error {
// Promote sets a user to admin.
var Promote action.GTSAction = func(ctx context.Context) error {
- dbConn, err := bundb.NewBunDBService(ctx)
+ var state state.State
+ state.Caches.Init()
+
+ dbConn, err := bundb.NewBunDBService(ctx, &state)
if err != nil {
return fmt.Errorf("error creating dbservice: %s", err)
}
+ // Set the state DB connection
+ state.DB = dbConn
+
username := config.GetAdminAccountUsername()
if username == "" {
return errors.New("no username set")
@@ -159,11 +178,17 @@ var Promote action.GTSAction = func(ctx context.Context) error {
// Demote sets admin on a user to false.
var Demote action.GTSAction = func(ctx context.Context) error {
- dbConn, err := bundb.NewBunDBService(ctx)
+ var state state.State
+ state.Caches.Init()
+
+ dbConn, err := bundb.NewBunDBService(ctx, &state)
if err != nil {
return fmt.Errorf("error creating dbservice: %s", err)
}
+ // Set the state DB connection
+ state.DB = dbConn
+
username := config.GetAdminAccountUsername()
if username == "" {
return errors.New("no username set")
@@ -193,11 +218,17 @@ var Demote action.GTSAction = func(ctx context.Context) error {
// Disable sets Disabled to true on a user.
var Disable action.GTSAction = func(ctx context.Context) error {
- dbConn, err := bundb.NewBunDBService(ctx)
+ var state state.State
+ state.Caches.Init()
+
+ dbConn, err := bundb.NewBunDBService(ctx, &state)
if err != nil {
return fmt.Errorf("error creating dbservice: %s", err)
}
+ // Set the state DB connection
+ state.DB = dbConn
+
username := config.GetAdminAccountUsername()
if username == "" {
return errors.New("no username set")
@@ -227,11 +258,17 @@ var Disable action.GTSAction = func(ctx context.Context) error {
// Password sets the password of target account.
var Password action.GTSAction = func(ctx context.Context) error {
- dbConn, err := bundb.NewBunDBService(ctx)
+ var state state.State
+ state.Caches.Init()
+
+ dbConn, err := bundb.NewBunDBService(ctx, &state)
if err != nil {
return fmt.Errorf("error creating dbservice: %s", err)
}
+ // Set the state DB connection
+ state.DB = dbConn
+
username := config.GetAdminAccountUsername()
if username == "" {
return errors.New("no username set")