Adds Shared Channel related API endpoints (#27436)
* Adds Shared Channel management API endpoints
New endpoints for the following routes are added:
- Get Shared Channel Remotes by Remote Cluster at `GET
/api/v4/remotecluster/{remote_id}/sharedchannelremotes`
- Invite Remote Cluster to Channel at `POST
/api/v4/remotecluster/{remote_id}/channels/invite`
- Uninvite Remote Cluster to Channel at `POST
/api/v4/remotecluster/{remote_id}/channels/uninvite`
These endpoints are planned to be used from the system console, and
gated through the `manage_secure_connections` permission.
* Adds i18n messages for API errors
* Fix pagination flaky test
* Fix linter
* Adds the posibility of filtering shared channel remotes by home
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
60ffd00d30
Коммит
3dc0e63c03
@@ -572,6 +572,14 @@ func (c *Client4) remoteClusterRoute() string {
|
||||
return "/remotecluster"
|
||||
}
|
||||
|
||||
func (c *Client4) sharedChannelRemotesRoute(remoteId string) string {
|
||||
return fmt.Sprintf("%s/%s/sharedchannelremotes", c.remoteClusterRoute(), remoteId)
|
||||
}
|
||||
|
||||
func (c *Client4) channelRemoteRoute(remoteId, channelId string) string {
|
||||
return fmt.Sprintf("%s/%s/channels/%s", c.remoteClusterRoute(), remoteId, channelId)
|
||||
}
|
||||
|
||||
func (c *Client4) sharedChannelsRoute() string {
|
||||
return "/sharedchannels"
|
||||
}
|
||||
@@ -8887,6 +8895,57 @@ func (c *Client4) DeleteRemoteCluster(ctx context.Context, remoteClusterId strin
|
||||
return BuildResponse(r), nil
|
||||
}
|
||||
|
||||
func (c *Client4) GetSharedChannelRemotesByRemoteCluster(ctx context.Context, remoteId string, excludeHome, excludeRemote bool, page, perPage int) ([]*SharedChannelRemote, *Response, error) {
|
||||
v := url.Values{}
|
||||
if excludeHome {
|
||||
v.Set("exclude_home", "true")
|
||||
}
|
||||
if excludeRemote {
|
||||
v.Set("exclude_remote", "true")
|
||||
}
|
||||
if page != 0 {
|
||||
v.Set("page", fmt.Sprintf("%d", page))
|
||||
}
|
||||
if perPage != 0 {
|
||||
v.Set("per_page", fmt.Sprintf("%d", perPage))
|
||||
}
|
||||
url := c.sharedChannelRemotesRoute(remoteId)
|
||||
if len(v) > 0 {
|
||||
url += "?" + v.Encode()
|
||||
}
|
||||
|
||||
r, err := c.DoAPIGet(ctx, url, "")
|
||||
if err != nil {
|
||||
return nil, BuildResponse(r), err
|
||||
}
|
||||
defer closeBody(r)
|
||||
|
||||
var scs []*SharedChannelRemote
|
||||
json.NewDecoder(r.Body).Decode(&scs)
|
||||
|
||||
return scs, BuildResponse(r), nil
|
||||
}
|
||||
|
||||
func (c *Client4) InviteRemoteClusterToChannel(ctx context.Context, remoteId, channelId string) (*Response, error) {
|
||||
url := fmt.Sprintf("%s/invite", c.channelRemoteRoute(remoteId, channelId))
|
||||
r, err := c.DoAPIPost(ctx, url, "")
|
||||
if err != nil {
|
||||
return BuildResponse(r), err
|
||||
}
|
||||
defer closeBody(r)
|
||||
return BuildResponse(r), nil
|
||||
}
|
||||
|
||||
func (c *Client4) UninviteRemoteClusterToChannel(ctx context.Context, remoteId, channelId string) (*Response, error) {
|
||||
url := fmt.Sprintf("%s/uninvite", c.channelRemoteRoute(remoteId, channelId))
|
||||
r, err := c.DoAPIPost(ctx, url, "")
|
||||
if err != nil {
|
||||
return BuildResponse(r), err
|
||||
}
|
||||
defer closeBody(r)
|
||||
return BuildResponse(r), nil
|
||||
}
|
||||
|
||||
func (c *Client4) GetAncillaryPermissions(ctx context.Context, subsectionPermissions []string) ([]string, *Response, error) {
|
||||
var returnedPermissions []string
|
||||
url := fmt.Sprintf("%s/ancillary", c.permissionsRoute())
|
||||
|
||||
@@ -263,6 +263,8 @@ type SharedChannelRemoteFilterOpts struct {
|
||||
ChannelId string
|
||||
RemoteId string
|
||||
InclUnconfirmed bool
|
||||
ExcludeHome bool
|
||||
ExcludeRemote bool
|
||||
}
|
||||
|
||||
// SyncMsg represents a change in content (post add/edit/delete, reaction add/remove, users).
|
||||
|
||||
Ссылка в новой задаче
Block a user