Cherry-pick 6404ab29acc04901c5cb1cf5ad97fc3c0693e2cd into release-10.11
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
989f3a36dc
Коммит
a07b1d7a8c
@@ -3637,6 +3637,23 @@ func (c *Client4) MoveChannel(ctx context.Context, channelId, teamId string, for
|
||||
return ch, BuildResponse(r), nil
|
||||
}
|
||||
|
||||
// GetGroupMessageMembersCommonTeams returns the set of teams in common for members of a GM channel.
|
||||
func (c *Client4) GetGroupMessageMembersCommonTeams(ctx context.Context, channelId string) ([]*Team, *Response, error) {
|
||||
r, err := c.DoAPIGet(ctx, c.channelRoute(channelId)+"/common_teams", "")
|
||||
if err != nil {
|
||||
return nil, BuildResponse(r), err
|
||||
}
|
||||
defer closeBody(r)
|
||||
|
||||
var teams []*Team
|
||||
err = json.NewDecoder(r.Body).Decode(&teams)
|
||||
if err != nil {
|
||||
return nil, BuildResponse(r), NewAppError("GetGroupMessageMembersCommonTeams", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
return teams, BuildResponse(r), nil
|
||||
}
|
||||
|
||||
// GetChannelByName returns a channel based on the provided channel name and team id strings.
|
||||
func (c *Client4) GetChannelByName(ctx context.Context, channelName, teamId string, etag string) (*Channel, *Response, error) {
|
||||
r, err := c.DoAPIGet(ctx, c.channelByNameRoute(channelName, teamId), etag)
|
||||
|
||||
@@ -491,3 +491,19 @@ func ExampleClient4_UpdateChannelScheme() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleClient4_GetGroupMessageMembersCommonTeams() {
|
||||
client := model.NewAPIv4Client(os.Getenv("MM_SERVICESETTINGS_SITEURL"))
|
||||
client.SetToken(os.Getenv("MM_AUTHTOKEN"))
|
||||
|
||||
channelID := "gm_channel_id"
|
||||
teams, _, err := client.GetGroupMessageMembersCommonTeams(context.Background(), channelID)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Found %d common teams for members of channel %s\n", len(teams), channelID)
|
||||
for _, team := range teams {
|
||||
fmt.Printf(" - %s (%s)\n", team.DisplayName, team.Name)
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user