diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2017-03-20 13:37:34 +0100 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2017-03-20 12:37:34 +0000 |
commit | ac8282cda1455802f52ebe6687eeeef6c950bf49 (patch) | |
tree | a0eb38c5de6c6605399f91bf35b0fc5434bd4911 /model | |
parent | 9b10f3ef5450886bc2eb47fc58b649ff67109b1d (diff) | |
download | chat-ac8282cda1455802f52ebe6687eeeef6c950bf49.tar.gz chat-ac8282cda1455802f52ebe6687eeeef6c950bf49.tar.bz2 chat-ac8282cda1455802f52ebe6687eeeef6c950bf49.zip |
Add updateConfig endpoint for apiV4 (#5706)
Diffstat (limited to 'model')
-rw-r--r-- | model/client4.go | 11 | ||||
-rw-r--r-- | model/config.go | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/model/client4.go b/model/client4.go index a2878df6f..307d52c55 100644 --- a/model/client4.go +++ b/model/client4.go @@ -1191,6 +1191,7 @@ func (c *Client4) DatabaseRecycle() (bool, *Response) { } } +// InvalidateCaches will purge the cache and can affect the performance while is cleaning. func (c *Client4) InvalidateCaches() (bool, *Response) { if r, err := c.DoApiPost(c.GetCacheRoute()+"/invalidate", ""); err != nil { return false, &Response{StatusCode: r.StatusCode, Error: err} @@ -1200,6 +1201,16 @@ func (c *Client4) InvalidateCaches() (bool, *Response) { } } +// UpdateConfig will update the server configuration +func (c *Client4) UpdateConfig(config *Config) (*Config, *Response) { + if r, err := c.DoApiPut(c.GetConfigRoute(), config.ToJson()); err != nil { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return ConfigFromJson(r.Body), BuildResponse(r) + } +} + // Webhooks Section // CreateIncomingWebhook creates an incoming webhook for a channel. diff --git a/model/config.go b/model/config.go index 86693b57e..8a2a5cc47 100644 --- a/model/config.go +++ b/model/config.go @@ -473,7 +473,7 @@ func (o *Config) SetDefaults() { *o.FileSettings.MaxFileSize = 52428800 // 50 MB } - if len(*o.FileSettings.PublicLinkSalt) == 0 { + if o.FileSettings.PublicLinkSalt == nil || len(*o.FileSettings.PublicLinkSalt) == 0 { o.FileSettings.PublicLinkSalt = new(string) *o.FileSettings.PublicLinkSalt = NewRandomString(32) } |