summaryrefslogtreecommitdiff
path: root/internal/api
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-07-08 15:05:19 +0200
committerLibravatar GitHub <noreply@github.com>2021-07-08 15:05:19 +0200
commitfe269cd64148cda67cc958d3c3c62f3858bfdc90 (patch)
treed3a7f007314339aa6c2beffc8267b15795990219 /internal/api
parentdisable html escaping for short description (#84) (diff)
downloadgotosocial-fe269cd64148cda67cc958d3c3c62f3858bfdc90.tar.xz
fix up some of the instance patching stuff (#85)
Diffstat (limited to 'internal/api')
-rw-r--r--internal/api/client/instance/instancepatch.go6
-rw-r--r--internal/api/model/instance.go24
2 files changed, 20 insertions, 10 deletions
diff --git a/internal/api/client/instance/instancepatch.go b/internal/api/client/instance/instancepatch.go
index 250e836be..1080574c4 100644
--- a/internal/api/client/instance/instancepatch.go
+++ b/internal/api/client/instance/instancepatch.go
@@ -25,7 +25,7 @@ func (m *Module) InstanceUpdatePATCHHandler(c *gin.Context) {
return
}
- l.Debugf("parsing request form %s", c.Request.Form)
+ l.Debug("parsing request form")
form := &model.InstanceSettingsUpdateRequest{}
if err := c.ShouldBind(&form); err != nil || form == nil {
l.Debugf("could not parse form from request: %s", err)
@@ -33,8 +33,10 @@ func (m *Module) InstanceUpdatePATCHHandler(c *gin.Context) {
return
}
+ l.Debugf("parsed form: %+v", form)
+
// if everything on the form is nil, then nothing has been set and we shouldn't continue
- if form.SiteTitle == nil && form.SiteContactUsername == nil && form.SiteContactEmail == nil && form.SiteShortDescription == nil && form.SiteDescription == nil && form.SiteTerms == nil && form.Avatar == nil && form.Header == nil {
+ if form.Title == nil && form.ContactUsername == nil && form.ContactEmail == nil && form.ShortDescription == nil && form.Description == nil && form.Terms == nil && form.Avatar == nil && form.Header == nil {
l.Debugf("could not parse form from request")
c.JSON(http.StatusBadRequest, gin.H{"error": "empty form submitted"})
return
diff --git a/internal/api/model/instance.go b/internal/api/model/instance.go
index 834c6fb55..c534de2d0 100644
--- a/internal/api/model/instance.go
+++ b/internal/api/model/instance.go
@@ -75,12 +75,20 @@ type InstanceStats struct {
// InstanceSettingsUpdateRequest is the form to be parsed on a PATCH to /api/v1/instance
type InstanceSettingsUpdateRequest struct {
- SiteTitle *string `form:"site_title" json:"site_title" xml:"site_title"`
- SiteContactUsername *string `form:"site_contact_username" json:"site_contact_username" xml:"site_contact_username"`
- SiteContactEmail *string `form:"site_contact_email" json:"site_contact_email" xml:"site_contact_email"`
- SiteShortDescription *string `form:"site_short_description" json:"site_short_description" xml:"site_short_description"`
- SiteDescription *string `form:"site_description" json:"site_description" xml:"site_description"`
- SiteTerms *string `form:"site_terms" json:"site_terms" xml:"site_terms"`
- Avatar *multipart.FileHeader `form:"avatar" json:"avatar" xml:"avatar"`
- Header *multipart.FileHeader `form:"header" json:"header" xml:"header"`
+ // Title to use for the instance. Max 40 characters.
+ Title *string `form:"title" json:"title" xml:"title"`
+ // Username for the instance contact account. Must be the username of an existing admin.
+ ContactUsername *string `form:"contact_username" json:"contact_username" xml:"contact_username"`
+ // Email for reaching the instance administrator(s).
+ ContactEmail *string `form:"contact_email" json:"contact_email" xml:"contact_email"`
+ // Short description of the instance, max 500 chars. HTML formatting accepted.
+ ShortDescription *string `form:"short_description" json:"short_description" xml:"short_description"`
+ // Longer description of the instance, max 5,000 chars. HTML formatting accepted.
+ Description *string `form:"description" json:"description" xml:"description"`
+ // Terms and conditions of the instance, max 5,000 chars. HTML formatting accepted.
+ Terms *string `form:"terms" json:"terms" xml:"terms"`
+ // Image to use as the instance thumbnail.
+ Avatar *multipart.FileHeader `form:"avatar" json:"avatar" xml:"avatar"`
+ // Image to use as the instance header.
+ Header *multipart.FileHeader `form:"header" json:"header" xml:"header"`
}