summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-08-15 12:35:05 +0200
committerLibravatar GitHub <noreply@github.com>2022-08-15 11:35:05 +0100
commitac6ed3d939fe9dad81aadbd04541e905c625ca82 (patch)
tree6116baf25675837dc99f69c49b9fec2ff112ce5c /cmd
parent[frontend] Sensitive media spoilers (#752) (diff)
downloadgotosocial-ac6ed3d939fe9dad81aadbd04541e905c625ca82.tar.xz
[chore] Update bun / sqlite versions; update gtsmodels (#754)
* upstep bun and sqlite versions * allow specific columns to be updated in the db * only update necessary columns for user * bit tidier * only update necessary fields of media_attachment * only update relevant instance fields * update tests * update only specific account columns * use bool pointers on gtsmodels includes attachment, status, account, user * update columns more selectively * test all default fields on new account insert * updating remaining bools on gtsmodels * initialize pointer fields when extracting AP emoji * copy bools properly * add copyBoolPtr convenience function + test it * initialize false bool ptrs a bit more neatly
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gotosocial/action/admin/account/account.go36
1 files changed, 26 insertions, 10 deletions
diff --git a/cmd/gotosocial/action/admin/account/account.go b/cmd/gotosocial/action/admin/account/account.go
index 05f5a776b..83b98ac72 100644
--- a/cmd/gotosocial/action/admin/account/account.go
+++ b/cmd/gotosocial/action/admin/account/account.go
@@ -97,10 +97,13 @@ var Confirm action.GTSAction = func(ctx context.Context) error {
return err
}
- u.Approved = true
+ updatingColumns := []string{"approved", "email", "confirmed_at", "updated_at"}
+ approved := true
+ u.Approved = &approved
u.Email = u.UnconfirmedEmail
u.ConfirmedAt = time.Now()
- if err := dbConn.UpdateByPrimaryKey(ctx, u); err != nil {
+ u.UpdatedAt = time.Now()
+ if err := dbConn.UpdateByPrimaryKey(ctx, u, updatingColumns...); err != nil {
return err
}
@@ -131,8 +134,12 @@ var Promote action.GTSAction = func(ctx context.Context) error {
if err := dbConn.GetWhere(ctx, []db.Where{{Key: "account_id", Value: a.ID}}, u); err != nil {
return err
}
- u.Admin = true
- if err := dbConn.UpdateByPrimaryKey(ctx, u); err != nil {
+
+ updatingColumns := []string{"admin", "updated_at"}
+ admin := true
+ u.Admin = &admin
+ u.UpdatedAt = time.Now()
+ if err := dbConn.UpdateByPrimaryKey(ctx, u, updatingColumns...); err != nil {
return err
}
@@ -163,8 +170,12 @@ var Demote action.GTSAction = func(ctx context.Context) error {
if err := dbConn.GetWhere(ctx, []db.Where{{Key: "account_id", Value: a.ID}}, u); err != nil {
return err
}
- u.Admin = false
- if err := dbConn.UpdateByPrimaryKey(ctx, u); err != nil {
+
+ updatingColumns := []string{"admin", "updated_at"}
+ admin := false
+ u.Admin = &admin
+ u.UpdatedAt = time.Now()
+ if err := dbConn.UpdateByPrimaryKey(ctx, u, updatingColumns...); err != nil {
return err
}
@@ -195,8 +206,12 @@ var Disable action.GTSAction = func(ctx context.Context) error {
if err := dbConn.GetWhere(ctx, []db.Where{{Key: "account_id", Value: a.ID}}, u); err != nil {
return err
}
- u.Disabled = true
- if err := dbConn.UpdateByPrimaryKey(ctx, u); err != nil {
+
+ updatingColumns := []string{"disabled", "updated_at"}
+ disabled := true
+ u.Disabled = &disabled
+ u.UpdatedAt = time.Now()
+ if err := dbConn.UpdateByPrimaryKey(ctx, u, updatingColumns...); err != nil {
return err
}
@@ -247,9 +262,10 @@ var Password action.GTSAction = func(ctx context.Context) error {
return fmt.Errorf("error hashing password: %s", err)
}
+ updatingColumns := []string{"encrypted_password", "updated_at"}
u.EncryptedPassword = string(pw)
-
- if err := dbConn.UpdateByPrimaryKey(ctx, u); err != nil {
+ u.UpdatedAt = time.Now()
+ if err := dbConn.UpdateByPrimaryKey(ctx, u, updatingColumns...); err != nil {
return err
}