MM-25737: Fix for groups list not returning results. (#14746)
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ca8a67c7cb
Коммит
18ddae2c1b
@@ -1225,7 +1225,16 @@ func (s *SqlGroupStore) GetGroups(page, perPage int, opts model.GroupSearchOpts)
|
|||||||
|
|
||||||
if opts.FilterParentTeamPermitted && len(opts.NotAssociatedToChannel) == 26 {
|
if opts.FilterParentTeamPermitted && len(opts.NotAssociatedToChannel) == 26 {
|
||||||
groupsQuery = groupsQuery.Where(`
|
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
|
SELECT
|
||||||
GroupId
|
GroupId
|
||||||
FROM
|
FROM
|
||||||
@@ -1241,7 +1250,9 @@ func (s *SqlGroupStore) GetGroups(page, perPage int, opts model.GroupSearchOpts)
|
|||||||
Id = ?
|
Id = ?
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
`, opts.NotAssociatedToChannel)
|
ELSE TRUE
|
||||||
|
END
|
||||||
|
`, opts.NotAssociatedToChannel, opts.NotAssociatedToChannel)
|
||||||
}
|
}
|
||||||
|
|
||||||
queryString, args, err := groupsQuery.ToSql()
|
queryString, args, err := groupsQuery.ToSql()
|
||||||
|
|||||||
@@ -3163,6 +3163,29 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
|||||||
|
|
||||||
endCreateTime := u2Update.New.UpdateAt + 1
|
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 {
|
testCases := []struct {
|
||||||
Name string
|
Name string
|
||||||
Page int
|
Page int
|
||||||
@@ -3373,6 +3396,15 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
|||||||
return groups[0].Id == group2.Id
|
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 {
|
for _, tc := range testCases {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user