diff options
Diffstat (limited to 'store')
-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 5ea04155d..91c27cf3e 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -1297,7 +1297,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 700a0e1d7..94fd30a6f 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) { |