[MM-16934] Add API endpoint to update channel privacy (#11993)

* Add API endpoint to update channel privacy setting

* Fix language files

* Improve tests by making sure channel has been updated correctly

* Improve tests
Этот коммит содержится в:
Claudio Costa
2019-09-16 19:34:36 +02:00
коммит произвёл GitHub
родитель 6a2f09ae78
Коммит ad9784d7e3
4 изменённых файлов: 126 добавлений и 0 удалений

Просмотреть файл

@@ -2100,6 +2100,17 @@ func (c *Client4) ConvertChannelToPrivate(channelId string) (*Channel, *Response
return ChannelFromJson(r.Body), BuildResponse(r)
}
// UpdateChannelPrivacy updates channel privacy
func (c *Client4) UpdateChannelPrivacy(channelId string, privacy string) (*Channel, *Response) {
requestBody := map[string]string{"privacy": privacy}
r, err := c.DoApiPut(c.GetChannelRoute(channelId)+"/privacy", MapToJson(requestBody))
if err != nil {
return nil, BuildErrorResponse(r, err)
}
defer closeBody(r)
return ChannelFromJson(r.Body), BuildResponse(r)
}
// RestoreChannel restores a previously deleted channel. Any missing fields are not updated.
func (c *Client4) RestoreChannel(channelId string) (*Channel, *Response) {
r, err := c.DoApiPost(c.GetChannelRoute(channelId)+"/restore", "")