MM-64632: Fix a panic in bulk import (#33360)
We were incorrect de-referencing the channels slice without checking for nil pointer first. https://mattermost.atlassian.net/browse/MM-64632 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
30ba6f573d
Коммит
c4dde3d0ab
@@ -791,16 +791,17 @@ func isValidGuestRoles(data UserImportData) bool {
|
||||
gtc++
|
||||
}
|
||||
|
||||
if *team.Channels != nil {
|
||||
for _, channel := range *team.Channels {
|
||||
if channel.Roles != nil && model.IsInRole(*channel.Roles, model.ChannelGuestRoleId) {
|
||||
ctc++
|
||||
}
|
||||
if team.Channels == nil {
|
||||
continue
|
||||
}
|
||||
for _, channel := range *team.Channels {
|
||||
if channel.Roles != nil && model.IsInRole(*channel.Roles, model.ChannelGuestRoleId) {
|
||||
ctc++
|
||||
}
|
||||
}
|
||||
|
||||
if ctc == len(*team.Channels) {
|
||||
isChannelGuest = true
|
||||
}
|
||||
if ctc == len(*team.Channels) {
|
||||
isChannelGuest = true
|
||||
}
|
||||
}
|
||||
if gtc == len(*data.Teams) {
|
||||
|
||||
@@ -1704,6 +1704,19 @@ func TestIsValidGuestRoles(t *testing.T) {
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "Valid case: User with team but nil channels array",
|
||||
input: UserImportData{
|
||||
Roles: model.NewPointer(model.SystemUserRoleId),
|
||||
Teams: &[]UserTeamImportData{
|
||||
{
|
||||
Roles: model.NewPointer(model.TeamUserRoleId),
|
||||
Channels: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Ссылка в новой задаче
Block a user