summaryrefslogtreecommitdiffstats
path: root/store/sql_user_store.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-23 06:34:22 -0400
committerGeorge Goldberg <george@gberg.me>2017-03-23 10:34:22 +0000
commit2a753949f10f70de26dba9fbff7c5ef9583d6c86 (patch)
tree4430844f254e62afdcf7b0e61da5870f2c8f7061 /store/sql_user_store.go
parent7e2e8238842c7d158211faafe03f814bffa78a8f (diff)
downloadchat-2a753949f10f70de26dba9fbff7c5ef9583d6c86.tar.gz
chat-2a753949f10f70de26dba9fbff7c5ef9583d6c86.tar.bz2
chat-2a753949f10f70de26dba9fbff7c5ef9583d6c86.zip
Implement POST /users/search endpoint for APIv4 (#5822)
* Implement POST /users/search endpoint for APIv4 * PLT-2713 Added store functions for searching users that don't have a team * PLT-2713 Added 'without_team' option when searching users * PLT-2713 Added 'without_team' option when searching users (v4)
Diffstat (limited to 'store/sql_user_store.go')
-rw-r--r--store/sql_user_store.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index 23b0c3696..c00e37ed6 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -1261,6 +1261,36 @@ func (us SqlUserStore) Search(teamId string, term string, options map[string]boo
return storeChannel
}
+func (us SqlUserStore) SearchWithoutTeam(term string, options map[string]bool) StoreChannel {
+ storeChannel := make(StoreChannel, 1)
+
+ go func() {
+ searchQuery := `
+ SELECT
+ *
+ FROM
+ Users
+ WHERE
+ (SELECT
+ COUNT(0)
+ FROM
+ TeamMembers
+ WHERE
+ TeamMembers.UserId = Users.Id
+ AND TeamMembers.DeleteAt = 0) = 0
+ SEARCH_CLAUSE
+ INACTIVE_CLAUSE
+ ORDER BY Username ASC
+ LIMIT 100`
+
+ storeChannel <- us.performSearch(searchQuery, term, options, map[string]interface{}{})
+ close(storeChannel)
+
+ }()
+
+ return storeChannel
+}
+
func (us SqlUserStore) SearchNotInChannel(teamId string, channelId string, term string, options map[string]bool) StoreChannel {
storeChannel := make(StoreChannel, 1)