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,7 +791,9 @@ func isValidGuestRoles(data UserImportData) bool {
|
|||||||
gtc++
|
gtc++
|
||||||
}
|
}
|
||||||
|
|
||||||
if *team.Channels != nil {
|
if team.Channels == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
for _, channel := range *team.Channels {
|
for _, channel := range *team.Channels {
|
||||||
if channel.Roles != nil && model.IsInRole(*channel.Roles, model.ChannelGuestRoleId) {
|
if channel.Roles != nil && model.IsInRole(*channel.Roles, model.ChannelGuestRoleId) {
|
||||||
ctc++
|
ctc++
|
||||||
@@ -802,7 +804,6 @@ func isValidGuestRoles(data UserImportData) bool {
|
|||||||
isChannelGuest = true
|
isChannelGuest = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if gtc == len(*data.Teams) {
|
if gtc == len(*data.Teams) {
|
||||||
isTeamGuest = true
|
isTeamGuest = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1704,6 +1704,19 @@ func TestIsValidGuestRoles(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expected: true,
|
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 {
|
for _, tc := range testCases {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user