Marks the RemoteTeamId field of RemoteClusters as deprecated (#27364)
* Marks the RemoteTeamId field of RemoteClusters as deprecated The `RemoteTeamId` was used both in the `RemoteCluster` model and as part of remote invites. It existed so two different remotes could have multiple secure connections between them, and have each of those connections scoped to a team, sharing through each only the channels that belong to their corresponding team. The way that we're thinking on the feature currently only contemplates one secure connection between two servers, and shares all the channels through that secure connection, so this field is no longer needed. As we don't have a system in place for the user to choose in which team a channel should be created from an invite, this change adds a mechanism that checks the invite for a teamId, and if it's not present, fetches a team from the database to create the channel into. This makes the change backwards compatible for secure connections that already have an established behavior and allows us to move forward with the implementation of an alternative. * Mark invite teamId field as deprecated --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6e5c741a7b
Коммит
d490fdc1d9
@@ -18,7 +18,7 @@ import (
|
||||
// channelInviteMsg represents an invitation for a remote cluster to start sharing a channel.
|
||||
type channelInviteMsg struct {
|
||||
ChannelId string `json:"channel_id"`
|
||||
TeamId string `json:"team_id"`
|
||||
TeamId string `json:"team_id"` // Deprecated: this field is no longer used. It's only kept for backwards compatibility.
|
||||
ReadOnly bool `json:"read_only"`
|
||||
Name string `json:"name"`
|
||||
DisplayName string `json:"display_name"`
|
||||
@@ -52,7 +52,6 @@ func (scs *Service) SendChannelInvite(channel *model.Channel, userId string, rc
|
||||
|
||||
invite := channelInviteMsg{
|
||||
ChannelId: channel.Id,
|
||||
TeamId: rc.RemoteTeamId,
|
||||
ReadOnly: sc.ReadOnly,
|
||||
Name: channel.Name,
|
||||
DisplayName: sc.ShareDisplayName,
|
||||
@@ -256,9 +255,21 @@ func (scs *Service) handleChannelCreation(invite channelInviteMsg, rc *model.Rem
|
||||
return scs.createDirectChannel(invite, rc)
|
||||
}
|
||||
|
||||
teamId := invite.TeamId
|
||||
// if the invite doesn't have a teamId associated and until the
|
||||
// acceptance of an invite includes selecting a team, we use the
|
||||
// first team of the list
|
||||
if teamId == "" {
|
||||
teams, err := scs.server.GetStore().Team().GetAllPage(0, 1, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get team to create the channel `%s`: %w", invite.ChannelId, err)
|
||||
}
|
||||
teamId = teams[0].Id
|
||||
}
|
||||
|
||||
channelNew := &model.Channel{
|
||||
Id: invite.ChannelId,
|
||||
TeamId: invite.TeamId,
|
||||
TeamId: teamId,
|
||||
Type: invite.Type,
|
||||
DisplayName: invite.DisplayName,
|
||||
Name: invite.Name,
|
||||
|
||||
Ссылка в новой задаче
Block a user