diff options
Diffstat (limited to 'vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/rest')
-rw-r--r-- | vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/rest/channels.go | 12 | ||||
-rw-r--r-- | vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/rest/permissions.go | 33 |
2 files changed, 43 insertions, 2 deletions
diff --git a/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/rest/channels.go b/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/rest/channels.go index 71377500..d5c8fa85 100644 --- a/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/rest/channels.go +++ b/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/rest/channels.go @@ -56,9 +56,17 @@ func (c *Client) LeaveChannel(channel *models.Channel) error { // https://rocket.chat/docs/developer-guides/rest-api/channels/info func (c *Client) GetChannelInfo(channel *models.Channel) (*models.Channel, error) { response := new(ChannelResponse) - if err := c.Get("channels.info", url.Values{"roomId": []string{channel.ID}}, response); err != nil { - return nil, err + switch { + case channel.Name != "" && channel.ID == "": + if err := c.Get("channels.info", url.Values{"roomName": []string{channel.Name}}, response); err != nil { + return nil, err + } + default: + if err := c.Get("channels.info", url.Values{"roomId": []string{channel.ID}}, response); err != nil { + return nil, err + } } return &response.Channel, nil } + diff --git a/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/rest/permissions.go b/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/rest/permissions.go new file mode 100644 index 00000000..2ccbd2f1 --- /dev/null +++ b/vendor/github.com/matterbridge/Rocket.Chat.Go.SDK/rest/permissions.go @@ -0,0 +1,33 @@ +package rest + +import ( + "bytes" + "encoding/json" + + "github.com/matterbridge/Rocket.Chat.Go.SDK/models" +) + +type UpdatePermissionsRequest struct { + Permissions []models.Permission `json:"permissions"` +} + +type UpdatePermissionsResponse struct { + Status + Permissions []models.Permission `json:"permissions"` +} + +// UpdatePermissions updates permissions +// +// https://rocket.chat/docs/developer-guides/rest-api/permissions/update/ +func (c *Client) UpdatePermissions(req *UpdatePermissionsRequest) (*UpdatePermissionsResponse, error) { + body, err := json.Marshal(req) + if err != nil { + return nil, err + } + + response := new(UpdatePermissionsResponse) + if err := c.Post("permissions.update", bytes.NewBuffer(body), response); err != nil { + return nil, err + } + return response, nil +} |