summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-11-03 14:52:25 -0500
committerJoramWilander <jwawilander@gmail.com>2015-11-03 14:52:25 -0500
commitfb5b57836ece6da2d0136802ca0d08346638b9e2 (patch)
tree1d63131f9a5bbf868a36adc782ad7b3bb9b3e305 /api
parentfc9aefb868db0f0c1b7490f7455c1adb43b59d2a (diff)
downloadchat-fb5b57836ece6da2d0136802ca0d08346638b9e2.tar.gz
chat-fb5b57836ece6da2d0136802ca0d08346638b9e2.tar.bz2
chat-fb5b57836ece6da2d0136802ca0d08346638b9e2.zip
Multiple fixes to major performance issues with teams with 50+ users
Diffstat (limited to 'api')
-rw-r--r--api/user.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/api/user.go b/api/user.go
index 732c6b9a8..42d3a43e7 100644
--- a/api/user.go
+++ b/api/user.go
@@ -49,7 +49,7 @@ func InitUser(r *mux.Router) {
sr.Handle("/newimage", ApiUserRequired(uploadProfileImage)).Methods("POST")
sr.Handle("/me", ApiAppHandler(getMe)).Methods("GET")
- sr.Handle("/status", ApiUserRequiredActivity(getStatuses, false)).Methods("GET")
+ sr.Handle("/status", ApiUserRequiredActivity(getStatuses, false)).Methods("POST")
sr.Handle("/profiles", ApiUserRequired(getProfiles)).Methods("GET")
sr.Handle("/profiles/{id:[A-Za-z0-9]+}", ApiUserRequired(getProfiles)).Methods("GET")
sr.Handle("/{id:[A-Za-z0-9]+}", ApiUserRequired(getUser)).Methods("GET")
@@ -1483,16 +1483,31 @@ func updateUserNotify(c *Context, w http.ResponseWriter, r *http.Request) {
}
func getStatuses(c *Context, w http.ResponseWriter, r *http.Request) {
+ userIds := model.ArrayFromJson(r.Body)
+ if len(userIds) == 0 {
+ c.SetInvalidParam("getStatuses", "userIds")
+ return
+ }
if result := <-Srv.Store.User().GetProfiles(c.Session.TeamId); result.Err != nil {
c.Err = result.Err
return
} else {
-
profiles := result.Data.(map[string]*model.User)
statuses := map[string]string{}
for _, profile := range profiles {
+ found := false
+ for _, uid := range userIds {
+ if uid == profile.Id {
+ found = true
+ }
+ }
+
+ if !found {
+ continue
+ }
+
if profile.IsOffline() {
statuses[profile.Id] = model.USER_OFFLINE
} else if profile.IsAway() {