diff options
author | Corey Hulen <corey@hulen.com> | 2015-10-19 09:56:34 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-10-19 09:56:34 -0700 |
commit | ea1b3129688dd76c80c7d41eec4f2eb60f9f0639 (patch) | |
tree | dadeed708df722d68d0344051fbdb9900a646c81 /api/web_conn.go | |
parent | d776d1aa0c7416a2c96da17e9cc2b7ad7f6a7fca (diff) | |
parent | 93eaa80a3bfacbb0c4a350474ca3d81b28b5d7ab (diff) | |
download | chat-ea1b3129688dd76c80c7d41eec4f2eb60f9f0639.tar.gz chat-ea1b3129688dd76c80c7d41eec4f2eb60f9f0639.tar.bz2 chat-ea1b3129688dd76c80c7d41eec4f2eb60f9f0639.zip |
Merge pull request #1072 from mattermost/plt-554
PLT-554 Small refactor of websocket code on client and server
Diffstat (limited to 'api/web_conn.go')
-rw-r--r-- | api/web_conn.go | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/api/web_conn.go b/api/web_conn.go index a5099e520..50a003ace 100644 --- a/api/web_conn.go +++ b/api/web_conn.go @@ -92,24 +92,9 @@ func (c *WebConn) writePump() { return } - if len(msg.ChannelId) > 0 { - allowed, ok := c.ChannelAccessCache[msg.ChannelId] - if !ok { - allowed = hasPermissionsToChannel(Srv.Store.Channel().CheckPermissionsTo(c.TeamId, msg.ChannelId, c.UserId)) - c.ChannelAccessCache[msg.ChannelId] = allowed - } - - if allowed { - c.WebSocket.SetWriteDeadline(time.Now().Add(WRITE_WAIT)) - if err := c.WebSocket.WriteJSON(msg); err != nil { - return - } - } - } else { - c.WebSocket.SetWriteDeadline(time.Now().Add(WRITE_WAIT)) - if err := c.WebSocket.WriteJSON(msg); err != nil { - return - } + c.WebSocket.SetWriteDeadline(time.Now().Add(WRITE_WAIT)) + if err := c.WebSocket.WriteJSON(msg); err != nil { + return } case <-ticker.C: @@ -121,9 +106,11 @@ func (c *WebConn) writePump() { } } -func (c *WebConn) updateChannelAccessCache(channelId string) { +func (c *WebConn) updateChannelAccessCache(channelId string) bool { allowed := hasPermissionsToChannel(Srv.Store.Channel().CheckPermissionsTo(c.TeamId, channelId, c.UserId)) c.ChannelAccessCache[channelId] = allowed + + return allowed } func hasPermissionsToChannel(sc store.StoreChannel) bool { |