[MM-19979] Stop sending new_user websocket event to guests (#13191)

* Stop sending new_user websocket event to guests

* Remove debug msg

* Revert go.mod/go.sum

* Fix linting issues
Этот коммит содержится в:
Claudio Costa
2019-11-28 14:24:04 +00:00
коммит произвёл GitHub
родитель 2259b7f2a8
Коммит eeec08c071
3 изменённых файлов: 104 добавлений и 7 удалений

Просмотреть файл

@@ -301,6 +301,28 @@ func (webCon *WebConn) SendHello() {
webCon.Send <- msg
}
func (webCon *WebConn) shouldSendEventToGuest(msg *model.WebSocketEvent) bool {
var userId string
var canSee bool
switch msg.Event {
case model.WEBSOCKET_EVENT_USER_UPDATED:
userId = msg.Data["user"].(*model.User).Id
case model.WEBSOCKET_EVENT_NEW_USER:
userId = msg.Data["user_id"].(string)
default:
return true
}
canSee, err := webCon.App.UserCanSeeOtherUser(webCon.UserId, userId)
if err != nil {
mlog.Error("webhub.shouldSendEvent.", mlog.Err(err))
return false
}
return canSee
}
func (webCon *WebConn) ShouldSendEvent(msg *model.WebSocketEvent) bool {
// IMPORTANT: Do not send event if WebConn does not have a session
if !webCon.IsAuthenticated() {
@@ -369,13 +391,8 @@ func (webCon *WebConn) ShouldSendEvent(msg *model.WebSocketEvent) bool {
return webCon.IsMemberOfTeam(msg.Broadcast.TeamId)
}
if msg.Event == model.WEBSOCKET_EVENT_USER_UPDATED && webCon.GetSession().Props[model.SESSION_PROP_IS_GUEST] == "true" {
canSee, err := webCon.App.UserCanSeeOtherUser(webCon.UserId, msg.Data["user"].(*model.User).Id)
if err != nil {
mlog.Error("webhub.shouldSendEvent.", mlog.Err(err))
return false
}
return canSee
if webCon.GetSession().Props[model.SESSION_PROP_IS_GUEST] == "true" {
return webCon.shouldSendEventToGuest(msg)
}
return true