happychat-service
Advanced tools
Comparing version 0.10.6 to 0.10.7
@@ -148,2 +148,16 @@ 'use strict'; | ||
var removeOperatorsFromChat = function removeOperatorsFromChat(chat) { | ||
var room = (0, _index.customerRoom)(chat.id); | ||
return getClients(operator_io, room).then(function (clients) { | ||
return Promise.all((0, _ramda.map)(function (socket) { | ||
return new Promise(function (resolve, reject) { | ||
socket.leave(room, function (e) { | ||
if (e) return reject(e); | ||
resolve(socket); | ||
}); | ||
}); | ||
}, clients)); | ||
}); | ||
}; | ||
var removeOperatorFromChat = function removeOperatorFromChat(operator, chat) { | ||
@@ -282,6 +296,6 @@ var customer_room_name = (0, _index.customerRoom)(chat.id); | ||
// remove all operator clients from the room | ||
store.dispatch((0, _actions.operatorInboundMessage)(chat.id, operator, (0, _ramda.merge)((0, _util.makeEventMessage)('operator left', chat.id), { meta: { operator: operator, event_type: 'leave' } }))); | ||
removeOperatorFromChat(operator, chat).then(function () { | ||
// send redux action to update loads | ||
debug('removed operator from chat', operator.id); | ||
store.dispatch((0, _actions.operatorInboundMessage)(chat.id, operator, (0, _ramda.merge)((0, _util.makeEventMessage)('operator left', chat.id), { meta: { operator: operator, event_type: 'leave' } }))); | ||
}, function (e) { | ||
@@ -321,2 +335,7 @@ return debug('failed to remove operator from chat', e); | ||
store.dispatch((0, _actions.operatorInboundMessage)(chat_id, operator, (0, _ramda.merge)((0, _util.makeEventMessage)('chat closed', chat_id), { meta: { event_type: 'close', by: action.operator } }))); | ||
removeOperatorsFromChat(chat).then(function () { | ||
return debug('removed all operators from chat stream', chat_id); | ||
}, function (e) { | ||
return debug('failed to remove operator sockets from chat', chat_id, e); | ||
}); | ||
}; | ||
@@ -323,0 +342,0 @@ |
{ | ||
"name": "happychat-service", | ||
"version": "0.10.6", | ||
"version": "0.10.7", | ||
"description": "Socket.IO based chat server for happychat.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
85884
1989