Implement some channel endpoints for APIv4 (#5846)
* Add v4 endpoint for getting the channels on a team for a user
* Implement PUT /channels/{channel_id}/patch endpoint for APIv4
* Implement POST /teams/{team_id}/channels/search endpoint for APIv4
* Update permission check
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
22715a31ed
Коммит
28a78d7607
@@ -897,6 +897,16 @@ func (c *Client4) UpdateChannel(channel *Channel) (*Channel, *Response) {
|
||||
}
|
||||
}
|
||||
|
||||
// PatchChannel partially updates a channel. Any missing fields are not updated.
|
||||
func (c *Client4) PatchChannel(channelId string, patch *ChannelPatch) (*Channel, *Response) {
|
||||
if r, err := c.DoApiPut(c.GetChannelRoute(channelId)+"/patch", patch.ToJson()); err != nil {
|
||||
return nil, &Response{StatusCode: r.StatusCode, Error: err}
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return ChannelFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
}
|
||||
|
||||
// CreateDirectChannel creates a direct message channel based on the two user
|
||||
// ids provided.
|
||||
func (c *Client4) CreateDirectChannel(userId1, userId2 string) (*Channel, *Response) {
|
||||
@@ -929,7 +939,7 @@ func (c *Client4) GetChannelStats(channelId string, etag string) (*ChannelStats,
|
||||
}
|
||||
}
|
||||
|
||||
// GetPublicChannelsForTeam returns a channel based on the provided team id string.
|
||||
// GetPublicChannelsForTeam returns a list of public channels based on the provided team id string.
|
||||
func (c *Client4) GetPublicChannelsForTeam(teamId string, page int, perPage int, etag string) (*ChannelList, *Response) {
|
||||
query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
|
||||
if r, err := c.DoApiGet(c.GetPublicChannelsForTeamRoute(teamId)+query, etag); err != nil {
|
||||
@@ -940,6 +950,26 @@ func (c *Client4) GetPublicChannelsForTeam(teamId string, page int, perPage int,
|
||||
}
|
||||
}
|
||||
|
||||
// GetChannelsForTeamForUser returns a list channels of on a team for a user.
|
||||
func (c *Client4) GetChannelsForTeamForUser(teamId, userId, etag string) (*ChannelList, *Response) {
|
||||
if r, err := c.DoApiGet(c.GetUserRoute(userId)+c.GetTeamRoute(teamId)+"/channels", etag); err != nil {
|
||||
return nil, &Response{StatusCode: r.StatusCode, Error: err}
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return ChannelListFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
}
|
||||
|
||||
// SearchChannels returns the channels on a team matching the provided search term.
|
||||
func (c *Client4) SearchChannels(teamId string, search *ChannelSearch) (*ChannelList, *Response) {
|
||||
if r, err := c.DoApiPost(c.GetTeamRoute(teamId)+"/channels/search", search.ToJson()); err != nil {
|
||||
return nil, &Response{StatusCode: r.StatusCode, Error: err}
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return ChannelListFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteChannel deletes channel based on the provided channel id string.
|
||||
func (c *Client4) DeleteChannel(channelId string) (bool, *Response) {
|
||||
if r, err := c.DoApiDelete(c.GetChannelRoute(channelId)); err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user