summaryrefslogtreecommitdiffstats
path: root/api/user.go
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-09-27 11:19:50 -0300
committerChristopher Speller <crspeller@gmail.com>2016-09-27 10:19:50 -0400
commit60347559c7fb857bd5afcd93e65b6e220625da79 (patch)
treedd60ee950e12a9c64f82a1d5239d9d3327aa7ae0 /api/user.go
parentbfca752940a13c874788b0c885d36b2b263bd4fb (diff)
downloadchat-60347559c7fb857bd5afcd93e65b6e220625da79.tar.gz
chat-60347559c7fb857bd5afcd93e65b6e220625da79.tar.bz2
chat-60347559c7fb857bd5afcd93e65b6e220625da79.zip
PLT-3734 Cleaning up shouldSendEvent function (#4024)
* PLT-3734 Cleaning up shouldSendEvent function * Fix LHS unread highlight and jewel mentions
Diffstat (limited to 'api/user.go')
-rw-r--r--api/user.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/api/user.go b/api/user.go
index e8040f74e..5b2024315 100644
--- a/api/user.go
+++ b/api/user.go
@@ -269,8 +269,8 @@ func CreateUser(user *model.User) (*model.User, *model.AppError) {
ruser.Sanitize(map[string]bool{})
- // This message goes to every channel, so the channelId is irrelevant
- go Publish(model.NewWebSocketEvent("", "", ruser.Id, model.WEBSOCKET_EVENT_NEW_USER))
+ // This message goes to everyone, so the teamId, channelId and userId are irrelevant
+ go Publish(model.NewWebSocketEvent(model.WEBSOCKET_EVENT_NEW_USER, "", "", "", nil))
return ruser, nil
}
@@ -1289,8 +1289,11 @@ func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
} else {
user := result.Data.(*model.User)
user = sanitizeProfile(c, user)
- message := model.NewWebSocketEvent("", "", c.Session.UserId, model.WEBSOCKET_EVENT_USER_UPDATED)
+ omitUsers := make(map[string]bool, 1)
+ omitUsers[user.Id] = true
+ message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_UPDATED, "", "", "", omitUsers)
message.Add("user", user)
+
go Publish(message)
}
@@ -1340,7 +1343,9 @@ func updateUser(c *Context, w http.ResponseWriter, r *http.Request) {
updatedUser := rusers[0]
updatedUser = sanitizeProfile(c, updatedUser)
- message := model.NewWebSocketEvent("", "", user.Id, model.WEBSOCKET_EVENT_USER_UPDATED)
+ omitUsers := make(map[string]bool, 1)
+ omitUsers[user.Id] = true
+ message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_UPDATED, "", "", "", omitUsers)
message.Add("user", updatedUser)
go Publish(message)
@@ -2496,8 +2501,12 @@ func userTyping(req *model.WebSocketRequest) (map[string]interface{}, *model.App
parentId = ""
}
- event := model.NewWebSocketEvent("", channelId, req.Session.UserId, model.WEBSOCKET_EVENT_TYPING)
+ omitUsers := make(map[string]bool, 1)
+ omitUsers[req.Session.UserId] = true
+
+ event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_TYPING, "", channelId, "", omitUsers)
event.Add("parent_id", parentId)
+ event.Add("user_id", req.Session.UserId)
go Publish(event)
return nil, nil