Fixing permalinks to channels your not a memeber of (#2805)

Этот коммит содержится в:
Christopher Speller
2016-04-27 16:02:58 -04:00
коммит произвёл Harrison Healey
родитель d962e175f8
Коммит fa807d8e43
13 изменённых файлов: 250 добавлений и 53 удалений

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

@@ -90,6 +90,10 @@ func (c *Client) GetChannelRoute(channelId string) string {
return fmt.Sprintf("/teams/%v/channels/%v", c.GetTeamId(), channelId)
}
func (c *Client) GetChannelNameRoute(channelName string) string {
return fmt.Sprintf("/teams/%v/channels/name/%v", c.GetTeamId(), channelName)
}
func (c *Client) DoPost(url, data, contentType string) (*http.Response, *AppError) {
rq, _ := http.NewRequest("POST", c.Url+url, strings.NewReader(data))
rq.Header.Set("Content-Type", contentType)
@@ -806,6 +810,15 @@ func (c *Client) JoinChannel(id string) (*Result, *AppError) {
}
}
func (c *Client) JoinChannelByName(name string) (*Result, *AppError) {
if r, err := c.DoApiPost(c.GetChannelNameRoute(name)+"/join", ""); err != nil {
return nil, err
} else {
return &Result{r.Header.Get(HEADER_REQUEST_ID),
r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
}
}
func (c *Client) LeaveChannel(id string) (*Result, *AppError) {
if r, err := c.DoApiPost(c.GetChannelRoute(id)+"/leave", ""); err != nil {
return nil, err