diff options
| author | 2024-04-02 11:29:46 +0200 | |
|---|---|---|
| committer | 2024-04-02 10:29:46 +0100 | |
| commit | 29972e2c93fec78085901c1200fda70c24ed4544 (patch) | |
| tree | 5c4a04468cc29676dc0dae29b0ccac24938f9107 /cmd/gotosocial/action/admin | |
| parent | [chore] Vendor mkdocs fonts; update docs dependencies (#2789) (diff) | |
| download | gotosocial-29972e2c93fec78085901c1200fda70c24ed4544.tar.xz | |
[feature] Add `enable` command to mirror existing `disable` command; update docs (#2792)
* [feature] add `enable` CLI command to mirror existing `disable` command
* update docs
Diffstat (limited to 'cmd/gotosocial/action/admin')
| -rw-r--r-- | cmd/gotosocial/action/admin/account/account.go | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/cmd/gotosocial/action/admin/account/account.go b/cmd/gotosocial/action/admin/account/account.go index 612f10cc8..e2fd82642 100644 --- a/cmd/gotosocial/action/admin/account/account.go +++ b/cmd/gotosocial/action/admin/account/account.go @@ -30,6 +30,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/log" "github.com/superseriousbusiness/gotosocial/internal/state" + "github.com/superseriousbusiness/gotosocial/internal/util" "github.com/superseriousbusiness/gotosocial/internal/validate" "golang.org/x/crypto/bcrypt" ) @@ -294,7 +295,43 @@ var Disable action.GTSAction = func(ctx context.Context) error { return err } - user.Disabled = func() *bool { d := true; return &d }() + user.Disabled = util.Ptr(true) + return state.DB.UpdateUser( + ctx, user, + "disabled", + ) +} + +// Enable sets Disabled to false on a user. +var Enable action.GTSAction = func(ctx context.Context) error { + state, err := initState(ctx) + if err != nil { + return err + } + + defer func() { + // Ensure state gets stopped on return. + if err := stopState(state); err != nil { + log.Error(ctx, err) + } + }() + + username := config.GetAdminAccountUsername() + if err := validate.Username(username); err != nil { + return err + } + + account, err := state.DB.GetAccountByUsernameDomain(ctx, username, "") + if err != nil { + return err + } + + user, err := state.DB.GetUserByAccountID(ctx, account.ID) + if err != nil { + return err + } + + user.Disabled = util.Ptr(false) return state.DB.UpdateUser( ctx, user, "disabled", |
