MM-12957: Fix moving a channel with no members. (#9841)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ffd92d5d48
Коммит
877e1b7f9a
@@ -1709,13 +1709,15 @@ func (a *App) MoveChannel(team *model.Team, channel *model.Channel, user *model.
|
|||||||
channelMemberIds = append(channelMemberIds, channelMember.UserId)
|
channelMemberIds = append(channelMemberIds, channelMember.UserId)
|
||||||
}
|
}
|
||||||
|
|
||||||
teamMembers, err2 := a.GetTeamMembersByIds(team.Id, channelMemberIds)
|
if len(channelMemberIds) > 0 {
|
||||||
if err2 != nil {
|
teamMembers, err2 := a.GetTeamMembersByIds(team.Id, channelMemberIds)
|
||||||
return err2
|
if err2 != nil {
|
||||||
}
|
return err2
|
||||||
|
}
|
||||||
|
|
||||||
if len(teamMembers) != len(*channelMembers) {
|
if len(teamMembers) != len(*channelMembers) {
|
||||||
return model.NewAppError("MoveChannel", "app.channel.move_channel.members_do_not_match.error", nil, "", http.StatusInternalServerError)
|
return model.NewAppError("MoveChannel", "app.channel.move_channel.members_do_not_match.error", nil, "", http.StatusInternalServerError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep instance of the previous team
|
// keep instance of the previous team
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/model"
|
|
||||||
"github.com/mattermost/mattermost-server/store"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/mattermost/mattermost-server/model"
|
||||||
|
"github.com/mattermost/mattermost-server/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPermanentDeleteChannel(t *testing.T) {
|
func TestPermanentDeleteChannel(t *testing.T) {
|
||||||
@@ -138,6 +139,22 @@ func TestMoveChannel(t *testing.T) {
|
|||||||
if err := th.App.MoveChannel(targetTeam, channel2, th.BasicUser, true); err != nil {
|
if err := th.App.MoveChannel(targetTeam, channel2, th.BasicUser, true); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test moving a channel with no members.
|
||||||
|
channel3 := &model.Channel{
|
||||||
|
DisplayName: "dn_" + model.NewId(),
|
||||||
|
Name: "name_" + model.NewId(),
|
||||||
|
Type: model.CHANNEL_OPEN,
|
||||||
|
TeamId: sourceTeam.Id,
|
||||||
|
CreatorId: th.BasicUser.Id,
|
||||||
|
}
|
||||||
|
|
||||||
|
var err *model.AppError
|
||||||
|
channel3, err = th.App.CreateChannel(channel3, false)
|
||||||
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
err = th.App.MoveChannel(targetTeam, channel3, th.BasicUser, false)
|
||||||
|
assert.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordTownSquare(t *testing.T) {
|
func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordTownSquare(t *testing.T) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user