mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
PLT-6254: Search not in teams include removed members. (#6020)
This commit is contained in:
@@ -1298,7 +1298,7 @@ func (us SqlUserStore) SearchNotInTeam(notInTeamId string, term string, options
|
|||||||
ON tm.UserId = Users.Id
|
ON tm.UserId = Users.Id
|
||||||
AND tm.TeamId = :NotInTeamId
|
AND tm.TeamId = :NotInTeamId
|
||||||
WHERE
|
WHERE
|
||||||
tm.UserId IS NULL
|
(tm.UserId IS NULL OR tm.DeleteAt != 0)
|
||||||
SEARCH_CLAUSE
|
SEARCH_CLAUSE
|
||||||
INACTIVE_CLAUSE
|
INACTIVE_CLAUSE
|
||||||
ORDER BY Users.Username ASC
|
ORDER BY Users.Username ASC
|
||||||
|
|||||||
@@ -1659,6 +1659,44 @@ func TestUserStoreSearch(t *testing.T) {
|
|||||||
t.Fatal("should not have found user")
|
t.Fatal("should not have found user")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check SearchNotInTeam finds previously deleted team members.
|
||||||
|
Must(store.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u4.Id}))
|
||||||
|
|
||||||
|
if r1 := <-store.User().SearchNotInTeam(tid, "simo", searchOptions); r1.Err != nil {
|
||||||
|
t.Fatal(r1.Err)
|
||||||
|
} else {
|
||||||
|
profiles := r1.Data.([]*model.User)
|
||||||
|
found := false
|
||||||
|
for _, profile := range profiles {
|
||||||
|
if profile.Id == u4.Id {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if found {
|
||||||
|
t.Fatal("should not have found user")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Must(store.Team().UpdateMember(&model.TeamMember{TeamId: tid, UserId: u4.Id, DeleteAt: model.GetMillis() - 1000}))
|
||||||
|
if r1 := <-store.User().SearchNotInTeam(tid, "simo", searchOptions); r1.Err != nil {
|
||||||
|
t.Fatal(r1.Err)
|
||||||
|
} else {
|
||||||
|
profiles := r1.Data.([]*model.User)
|
||||||
|
found := false
|
||||||
|
for _, profile := range profiles {
|
||||||
|
if profile.Id == u4.Id {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
t.Fatal("should have found user")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUserStoreSearchWithoutTeam(t *testing.T) {
|
func TestUserStoreSearchWithoutTeam(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user