From cbb34a928fde5c3a0bf73ee11b7b73e65da900c2 Mon Sep 17 00:00:00 2001 From: claudemiro Date: Sun, 17 Jan 2016 00:12:12 -0200 Subject: [PATCH] Verify if the exist the channel before --- ipe/websockets.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ipe/websockets.go b/ipe/websockets.go index c439654..1e9e0e8 100644 --- a/ipe/websockets.go +++ b/ipe/websockets.go @@ -186,15 +186,15 @@ func onMessage(conn *websocket.Conn, w http.ResponseWriter, r *http.Request, ses channel, err := app.FindChannelByChannelID(clientEvent.Channel) + if err != nil { + emitWSError(newGenericError(fmt.Sprintf("Could not find a channel with the id %s", clientEvent.Channel)), conn) + } + if !channel.IsPresenceOrPrivate() { emitWSError(newGenericError("Client event rejected - only supported on private and presence channels"), conn) break } - if err != nil { - emitWSError(newGenericError(fmt.Sprintf("Could not find a channel with the id %s", clientEvent.Channel)), conn) - } - if err := app.Publish(channel, clientEvent, sessionID); err != nil { log.Error(err) emitWSError(newGenericReconnectImmediatelyError(), conn)