MM-25737: Fix for groups list not returning results. (#14746)

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Martin Kraft
2020-06-04 11:31:07 -04:00
коммит произвёл GitHub
родитель ca8a67c7cb
Коммит 18ddae2c1b
2 изменённых файлов: 45 добавлений и 2 удалений

Просмотреть файл

@@ -1225,7 +1225,16 @@ func (s *SqlGroupStore) GetGroups(page, perPage int, opts model.GroupSearchOpts)
if opts.FilterParentTeamPermitted && len(opts.NotAssociatedToChannel) == 26 {
groupsQuery = groupsQuery.Where(`
g.Id IN (
CASE
WHEN (
SELECT
Teams.GroupConstrained
FROM
Teams
JOIN Channels ON Channels.TeamId = Teams.Id
WHERE
Channels.Id = ?
) THEN g.Id IN (
SELECT
GroupId
FROM
@@ -1241,7 +1250,9 @@ func (s *SqlGroupStore) GetGroups(page, perPage int, opts model.GroupSearchOpts)
Id = ?
)
)
`, opts.NotAssociatedToChannel)
ELSE TRUE
END
`, opts.NotAssociatedToChannel, opts.NotAssociatedToChannel)
}
queryString, args, err := groupsQuery.ToSql()

Просмотреть файл

@@ -3163,6 +3163,29 @@ func testGetGroups(t *testing.T, ss store.Store) {
endCreateTime := u2Update.New.UpdateAt + 1
// Create Team3
team3 := &model.Team{
DisplayName: "Team3",
Description: model.NewId(),
CompanyName: model.NewId(),
AllowOpenInvite: false,
InviteId: model.NewId(),
Name: "zz" + model.NewId(),
Email: "success+" + model.NewId() + "@simulator.amazonses.com",
Type: model.TEAM_INVITE,
}
team3, err = ss.Team().Save(team3)
require.Nil(t, err)
channel4 := &model.Channel{
TeamId: team3.Id,
DisplayName: "Channel4",
Name: model.NewId(),
Type: model.CHANNEL_PRIVATE,
}
channel4, nErr = ss.Channel().Save(channel4, 9999)
require.Nil(t, nErr)
testCases := []struct {
Name string
Page int
@@ -3373,6 +3396,15 @@ func testGetGroups(t *testing.T, ss store.Store) {
return groups[0].Id == group2.Id
},
},
{
Name: "Non-group constrained team with no associated groups still returns groups for the child channel",
Opts: model.GroupSearchOpts{NotAssociatedToChannel: channel4.Id, FilterParentTeamPermitted: true},
Page: 0,
PerPage: 100,
Resultf: func(groups []*model.Group) bool {
return len(groups) > 0
},
},
}
for _, tc := range testCases {