summaryrefslogtreecommitdiff
path: root/internal/processing/account/update.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/processing/account/update.go')
-rw-r--r--internal/processing/account/update.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/processing/account/update.go b/internal/processing/account/update.go
index a96c17eeb..76f7a5a54 100644
--- a/internal/processing/account/update.go
+++ b/internal/processing/account/update.go
@@ -165,6 +165,26 @@ func (p *Processor) Update(ctx context.Context, account *gtsmodel.Account, form
account.EnableRSS = form.EnableRSS
}
+ if form.FieldsAttributes != nil && len(*form.FieldsAttributes) != 0 {
+ if err := validate.ProfileFieldsCount(*form.FieldsAttributes); err != nil {
+ return nil, gtserror.NewErrorBadRequest(err)
+ }
+
+ account.Fields = make([]gtsmodel.Field, 0) // reset fields
+ for _, f := range *form.FieldsAttributes {
+ if f.Name != nil && f.Value != nil {
+ if *f.Name != "" && *f.Value != "" {
+ field := gtsmodel.Field{}
+
+ field.Name = validate.ProfileField(f.Name)
+ field.Value = validate.ProfileField(f.Value)
+
+ account.Fields = append(account.Fields, field)
+ }
+ }
+ }
+ }
+
err := p.state.DB.UpdateAccount(ctx, account)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("could not update account %s: %s", account.ID, err))