summaryrefslogtreecommitdiffstats
path: root/store/sql_user_store.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-03-29 21:11:40 -0400
committerJoram Wilander <jwawilander@gmail.com>2017-03-29 21:11:40 -0400
commit6ac87d82e38c83e3b9b3bd12c3122e047f0110b1 (patch)
treeaa3f0f8f41df7c987f8bb62756ca3d8259ecbaa1 /store/sql_user_store.go
parenta4764a5c10ec59820eec7338d97be48d41c1a4d6 (diff)
downloadchat-6ac87d82e38c83e3b9b3bd12c3122e047f0110b1.tar.gz
chat-6ac87d82e38c83e3b9b3bd12c3122e047f0110b1.tar.bz2
chat-6ac87d82e38c83e3b9b3bd12c3122e047f0110b1.zip
PLT-2713 Added ability for admins to list users not in any team (#5844)
* PLT-2713 Added ability for admins to list users not in any team * Updated style of unit test
Diffstat (limited to 'store/sql_user_store.go')
-rw-r--r--store/sql_user_store.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index 092f4abc7..2fb7158ac 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -726,6 +726,54 @@ func (us SqlUserStore) GetProfilesNotInChannel(teamId string, channelId string,
return storeChannel
}
+func (us SqlUserStore) GetProfilesWithoutTeam(offset int, limit int) StoreChannel {
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ var users []*model.User
+
+ query := `
+ SELECT
+ *
+ FROM
+ Users
+ WHERE
+ (SELECT
+ COUNT(0)
+ FROM
+ TeamMembers
+ WHERE
+ TeamMembers.UserId = Users.Id
+ AND TeamMembers.DeleteAt = 0) = 0
+ ORDER BY
+ Username ASC
+ LIMIT
+ :Limit
+ OFFSET
+ :Offset`
+
+ if _, err := us.GetReplica().Select(&users, query, map[string]interface{}{"Offset": offset, "Limit": limit}); err != nil {
+ result.Err = model.NewLocAppError("SqlUserStore.GetProfilesWithoutTeam", "store.sql_user.get_profiles.app_error", nil, err.Error())
+ } else {
+
+ for _, u := range users {
+ u.Password = ""
+ u.AuthData = new(string)
+ *u.AuthData = ""
+ }
+
+ result.Data = users
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
func (us SqlUserStore) GetProfilesByUsernames(usernames []string, teamId string) StoreChannel {
storeChannel := make(StoreChannel)