Subversion Repository Public Repository

Nextrek

Diff Revisions 1125 vs 1126 for /socketIO/index.js

Diff revisions: vs.
  @@ -57,6 +57,7 @@
57 57
58 58 let user = undefined;
59 59 const EVENTS = Chat.EVENTS;
60 + const ERRORS = Chat.ERRORS;
60 61 const ROLES = Chat.ROLES;
61 62 const DEFAULT_ROOMS = Chat.DEFAULT_ROOMS;
62 63 let event = '';
  @@ -104,6 +105,10 @@
104 105
105 106 // join room
106 107 socket.on(EVENTS.ROOM.JOIN, (data) => {
108 + if (!user) {
109 + return
110 + }
111 +
107 112 const ownerRoom = Chat.joinOwnerRoom(data.user, user);
108 113 socket.join(ownerRoom);
109 114
  @@ -116,6 +121,10 @@
116 121
117 122 // send text message
118 123 socket.on(EVENTS.SEND.MESSAGE, (data) => {
124 + if (!user) {
125 + return
126 + }
127 +
119 128 const room = user.role === ROLES.CUSTOMER ? user.room : data.room;
120 129
121 130 const message = Chat.message(data, room, user);