fix up some of the instance patching stuff (#85)

This commit is contained in:
Tobi Smethurst
2021-07-08 15:05:19 +02:00
committed by GitHub
parent fd0714cfde
commit fe269cd641
3 changed files with 39 additions and 29 deletions

View File

@ -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