diff options
author | 2023-06-16 12:16:04 +0300 | |
---|---|---|
committer | 2023-06-16 11:16:04 +0200 | |
commit | 0fa06c0cde19ba5a4b77aa8372509cf9116fc546 (patch) | |
tree | d1e8299bb1a4c41db82f3e4c7926003bd067288d /internal/api/client/accounts/accountupdate.go | |
parent | [chore/bugfix] Demote failed inbox forwarding to warn log rather than error r... (diff) | |
download | gotosocial-0fa06c0cde19ba5a4b77aa8372509cf9116fc546.tar.xz |
[bugfix] Accept non-multipart forms for account updates (#1896)
* [bugfix] Update Swagger schema per max_profile_fields addition
* [bugfix] Accept non-multipart forms for account updates
Diffstat (limited to 'internal/api/client/accounts/accountupdate.go')
-rw-r--r-- | internal/api/client/accounts/accountupdate.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/internal/api/client/accounts/accountupdate.go b/internal/api/client/accounts/accountupdate.go index 26af29118..9c51f5924 100644 --- a/internal/api/client/accounts/accountupdate.go +++ b/internal/api/client/accounts/accountupdate.go @@ -43,6 +43,7 @@ import ( // // consumes: // - multipart/form-data +// - application/x-www-form-urlencoded // - application/json // // produces: @@ -213,6 +214,17 @@ func parseUpdateAccountForm(c *gin.Context) (*apimodel.UpdateCredentialsRequest, if err != nil { return nil, fmt.Errorf("custom json binding failed: %w", err) } + case binding.MIMEPOSTForm: + // Bind with default form binding first. + if err := c.ShouldBindWith(form, binding.FormPost); err != nil { + return nil, err + } + + // Now use custom form binding for + // field attributes in the form data. + if err := c.ShouldBindWith(form, fieldsAttributesFormBinding{}); err != nil { + return nil, fmt.Errorf("custom form binding failed: %w", err) + } case binding.MIMEMultipartPOSTForm: // Bind with default form binding first. if err := c.ShouldBindWith(form, binding.FormMultipart); err != nil { @@ -225,7 +237,7 @@ func parseUpdateAccountForm(c *gin.Context) (*apimodel.UpdateCredentialsRequest, return nil, fmt.Errorf("custom form binding failed: %w", err) } default: - err := fmt.Errorf("content-type %s not supported for this endpoint; supported content-types are %s, %s", ct, binding.MIMEJSON, binding.MIMEMultipartPOSTForm) + err := fmt.Errorf("content-type %s not supported for this endpoint; supported content-types are %s, %s, %s", ct, binding.MIMEJSON, binding.MIMEPOSTForm, binding.MIMEMultipartPOSTForm) return nil, err } |