diff options
author | George Goldberg <george@gberg.me> | 2017-04-07 19:49:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-07 19:49:02 +0100 |
commit | ad2ab81ee43a8652f66e89a738b5282befdd479b (patch) | |
tree | deb2625e18cbf63e220394fb11f831bf85a05e26 | |
parent | de3995a1ce0a5607ab791d38e882b406e2bb3952 (diff) | |
download | chat-ad2ab81ee43a8652f66e89a738b5282befdd479b.tar.gz chat-ad2ab81ee43a8652f66e89a738b5282befdd479b.tar.bz2 chat-ad2ab81ee43a8652f66e89a738b5282befdd479b.zip |
PLT-6254: Search not in teams include removed members. (#6020)
-rw-r--r-- | store/sql_user_store.go | 2 | ||||
-rw-r--r-- | store/sql_user_store_test.go | 38 |
2 files changed, 39 insertions, 1 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go index 1a8ff5c90..2b1d34ea9 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -1298,7 +1298,7 @@ func (us SqlUserStore) SearchNotInTeam(notInTeamId string, term string, options ON tm.UserId = Users.Id AND tm.TeamId = :NotInTeamId WHERE - tm.UserId IS NULL + (tm.UserId IS NULL OR tm.DeleteAt != 0) SEARCH_CLAUSE INACTIVE_CLAUSE ORDER BY Users.Username ASC diff --git a/store/sql_user_store_test.go b/store/sql_user_store_test.go index bfd74d55a..84b7712aa 100644 --- a/store/sql_user_store_test.go +++ b/store/sql_user_store_test.go @@ -1659,6 +1659,44 @@ func TestUserStoreSearch(t *testing.T) { 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) { |