happychat-service
Advanced tools
Comparing version 0.10.8-2 to 0.10.8-3
@@ -32,2 +32,4 @@ 'use strict'; | ||
var CUSTOMER_DISCONNECT = exports.CUSTOMER_DISCONNECT = 'CUSTOMER_DISCONNECT'; | ||
var AUTOCLOSE_CHAT = exports.AUTOCLOSE_CHAT = 'AUTOCLOSE_CHAT'; | ||
var CUSTOMER_LEFT = exports.CUSTOMER_LEFT = 'CUSTOMER_LEFT'; | ||
@@ -188,2 +190,14 @@ var reassignChats = exports.reassignChats = function reassignChats(operator, socket) { | ||
}; | ||
}; | ||
var customerLeft = exports.customerLeft = function customerLeft(id) { | ||
return { | ||
type: CUSTOMER_LEFT, id: id | ||
}; | ||
}; | ||
var autocloseChat = exports.autocloseChat = function autocloseChat(id) { | ||
return { | ||
type: AUTOCLOSE_CHAT, id: id | ||
}; | ||
}; |
@@ -55,2 +55,3 @@ 'use strict'; | ||
case _actions.CLOSE_CHAT: | ||
case _actions.AUTOCLOSE_CHAT: | ||
return setStatus(STATUS_CLOSED, state); | ||
@@ -71,2 +72,3 @@ case _actions.SET_CHAT_OPERATOR: | ||
case _actions2.OPERATOR_CHAT_JOIN: | ||
case _actions.OPERATOR_JOIN: | ||
return setMembers((0, _ramda.set)((0, _ramda.lensProp)(action.user.id), true, membersView(state)), state); | ||
@@ -82,7 +84,8 @@ case _actions2.OPERATOR_OPEN_CHAT_FOR_CLIENTS: | ||
var whereOperatorIs = function whereOperatorIs(id) { | ||
return (0, _ramda.compose)((0, _ramda.whereEq)({ id: id }), (0, _ramda.defaultTo)({}), operatorView); | ||
return (0, _ramda.compose)((0, _ramda.whereEq)({ id: id }), (0, _ramda.tap)(function (v) { | ||
return console.error('wth?', id, v); | ||
}), (0, _ramda.defaultTo)({}), operatorView); | ||
}; | ||
var whenOperatorIs = function whenOperatorIs(id) { | ||
return (0, _ramda.when)(whereOperatorIs(id)); | ||
var whereStatusIsNot = function whereStatusIsNot(status) { | ||
return (0, _ramda.compose)(_ramda.not, (0, _ramda.equals)(status), statusView); | ||
}; | ||
@@ -95,2 +98,4 @@ | ||
switch (action.type) { | ||
case _actions.AUTOCLOSE_CHAT: | ||
return (0, _ramda.assoc)(action.id, chat((0, _ramda.view)((0, _ramda.lensProp)(action.id), state), action), state); | ||
case _actions.SET_CHAT_MISSED: | ||
@@ -107,4 +112,5 @@ case _actions.SET_CHAT_OPERATOR: | ||
case _actions.ASSIGN_CHAT: | ||
case _actions.OPERATOR_JOIN: | ||
var lens = (0, _ramda.lensProp)(action.chat.id); | ||
return (0, _ramda.set)(lens, chat((0, _ramda.view)(lens, state), action))(state); | ||
return (0, _ramda.assoc)((0, _util.asString)(action.chat.id), chat((0, _ramda.view)(lens, state), action))(state); | ||
case _actions.SET_CHATS_RECOVERED: | ||
@@ -115,3 +121,3 @@ return (0, _ramda.reduce)(function (chats, chat_id) { | ||
case _actions.SET_OPERATOR_CHATS_ABANDONED: | ||
return (0, _ramda.map)(whenOperatorIs(action.operator_id)(function (value) { | ||
return (0, _ramda.map)((0, _ramda.when)((0, _ramda.both)(whereOperatorIs(action.operator_id), whereStatusIsNot(STATUS_CLOSED)), function (value) { | ||
return chat(value, action); | ||
@@ -118,0 +124,0 @@ }))(state); |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.isAssigningChat = exports.getNextMissedChat = exports.haveMissedChat = exports.getNextPendingChat = exports.havePendingChat = exports.haveChatWithStatus = exports.isChatStatusClosed = exports.isChatStatusNew = exports.getChatStatus = exports.getChats = exports.getChat = exports.getChatOperator = exports.getMissedChats = exports.getAbandonedChats = exports.getOperatorAbandonedChats = exports.getChatsWithStatus = exports.getAllChats = exports.getOpenChatMembers = exports.getChatMembers = exports.getChatsForOperator = undefined; | ||
exports.isAssigningChat = exports.getNextMissedChat = exports.haveMissedChat = exports.getNextPendingChat = exports.havePendingChat = exports.haveChatWithStatus = exports.isChatStatusClosed = exports.isChatStatusNew = exports.getChatStatus = exports.getChats = exports.getChat = exports.getChatOperator = exports.getMissedChats = exports.getAbandonedChats = exports.getOperatorAbandonedChats = exports.getChatsWithStatus = exports.getAllChats = exports.getOpenChatMembers = exports.getChatMembers = exports.getOpenChatsForOperator = exports.getChatsForOperator = undefined; | ||
@@ -32,7 +32,21 @@ var _ramda = require('ramda'); | ||
// take the 3rd item in chat row [STATUS, CHAT, OPERATOR] | ||
// take the 3rd item in chat row [STATUS, CHAT, OPERATOR] | ||
_reducer.operatorView)), | ||
// get the values of chat | ||
// get the values of chat | ||
_ramda.values, selectChatlist)(state); | ||
}; | ||
var getOpenChatsForOperator = exports.getOpenChatsForOperator = function getOpenChatsForOperator(operator_id, state) { | ||
return (0, _ramda.compose)( | ||
// take the 2nd item (the chat) | ||
mapToChat, | ||
// filter the values of chat | ||
(0, _ramda.filter)((0, _ramda.both)((0, _ramda.compose)( | ||
// compare operator.id to operator_id and match when equal | ||
(0, _ramda.whereEq)({ id: operator_id }), (0, _ramda.defaultTo)({}), _reducer.operatorView), (0, _ramda.compose)(_ramda.not, (0, _ramda.equals)(_reducer.STATUS_CLOSED), _reducer.statusView))), _ramda.values, selectChatlist)(state); | ||
}; | ||
var getChatMembers = exports.getChatMembers = (0, _ramda.compose)(mapToMembers, _ramda.values, selectChatlist); | ||
@@ -39,0 +53,0 @@ var getOpenChatMembers = exports.getOpenChatMembers = (0, _ramda.compose)(mapToMembers, filterClosed, _ramda.values, selectChatlist); |
@@ -16,7 +16,7 @@ 'use strict'; | ||
var onAuthorized = function onAuthorized(_ref) { | ||
var socket = _ref.socket; | ||
var agent = _ref.agent; | ||
var store = _ref.store; | ||
var getState = store.getState; | ||
var dispatch = store.dispatch; | ||
var socket = _ref.socket, | ||
agent = _ref.agent, | ||
store = _ref.store; | ||
var getState = store.getState, | ||
dispatch = store.dispatch; | ||
// any message sent from a customer needs to be forwarded to the agent socket | ||
@@ -23,0 +23,0 @@ /** |
@@ -52,11 +52,10 @@ 'use strict'; | ||
return function (_ref) { | ||
var getState = _ref.getState; | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState, | ||
dispatch = _ref.dispatch; | ||
debug('initialized broadcaster'); | ||
var _jsondiff = (0, _simperiumJsondiff2.default)(); | ||
var _jsondiff = (0, _simperiumJsondiff2.default)(), | ||
diff = _jsondiff.diff; | ||
var diff = _jsondiff.diff; | ||
var version = (0, _uuid.v4)(); | ||
@@ -63,0 +62,0 @@ var currentState = selector(getState()); |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _reduxDelayedDispatch = require('redux-delayed-dispatch'); | ||
var _actions = require('../../chat-list/actions'); | ||
@@ -30,6 +32,6 @@ | ||
var identityForUser = function identityForUser(_ref) { | ||
var id = _ref.id; | ||
var name = _ref.name; | ||
var username = _ref.username; | ||
var picture = _ref.picture; | ||
var id = _ref.id, | ||
name = _ref.name, | ||
username = _ref.username, | ||
picture = _ref.picture; | ||
return { id: id, name: name, username: username, picture: picture }; | ||
@@ -65,7 +67,7 @@ }; | ||
var init = function init(_ref2) { | ||
var user = _ref2.user; | ||
var socket = _ref2.socket; | ||
var io = _ref2.io; | ||
var store = _ref2.store; | ||
var chat = _ref2.chat; | ||
var user = _ref2.user, | ||
socket = _ref2.socket, | ||
io = _ref2.io, | ||
store = _ref2.store, | ||
chat = _ref2.chat; | ||
return function () { | ||
@@ -75,5 +77,5 @@ debug('chat initialized', chat); | ||
socket.on('message', function (_ref3) { | ||
var text = _ref3.text; | ||
var id = _ref3.id; | ||
var meta = _ref3.meta; | ||
var text = _ref3.text, | ||
id = _ref3.id, | ||
meta = _ref3.meta; | ||
@@ -106,6 +108,6 @@ var message = { session_id: chat.id, id: id, text: text, timestamp: (0, _util.timestamp)(), user: identityForUser(user), meta: meta }; | ||
var join = function join(_ref4) { | ||
var io = _ref4.io; | ||
var user = _ref4.user; | ||
var socket = _ref4.socket; | ||
var store = _ref4.store; | ||
var io = _ref4.io, | ||
user = _ref4.user, | ||
socket = _ref4.socket, | ||
store = _ref4.store; | ||
@@ -137,7 +139,9 @@ debug('user joined', user); | ||
exports.default = function (_ref5, customerAuth) { | ||
var io = _ref5.io; | ||
var _ref5$timeout = _ref5.timeout; | ||
var timeout = _ref5$timeout === undefined ? 1000 : _ref5$timeout; | ||
var _ref5$customerDisconn = _ref5.customerDisconnectTimeout; | ||
var customerDisconnectTimeout = _ref5$customerDisconn === undefined ? 90000 : _ref5$customerDisconn; | ||
var io = _ref5.io, | ||
_ref5$timeout = _ref5.timeout, | ||
timeout = _ref5$timeout === undefined ? 1000 : _ref5$timeout, | ||
_ref5$customerDisconn = _ref5.customerDisconnectTimeout, | ||
customerDisconnectTimeout = _ref5$customerDisconn === undefined ? 90000 : _ref5$customerDisconn, | ||
_ref5$customerDisconn2 = _ref5.customerDisconnectMessageTimeout, | ||
customerDisconnectMessageTimeout = _ref5$customerDisconn2 === undefined ? 10000 : _ref5$customerDisconn2; | ||
return function (store) { | ||
@@ -215,4 +219,4 @@ var operator_io = io.of('/operator'); | ||
var handleCustomerReceiveMessage = function handleCustomerReceiveMessage(action) { | ||
var id = action.id; | ||
var message = action.message; | ||
var id = action.id, | ||
message = action.message; | ||
@@ -224,4 +228,4 @@ debug('sending message to customer', (0, _index.customerRoom)(id), message.text); | ||
var handleCustomerReceiveTyping = function handleCustomerReceiveTyping(action) { | ||
var id = action.id; | ||
var text = action.text; | ||
var id = action.id, | ||
text = action.text; | ||
@@ -232,4 +236,4 @@ customer_io.to((0, _index.customerRoom)(id)).emit('typing', text && !(0, _ramda.isEmpty)(text)); | ||
var handleCustomerJoin = function handleCustomerJoin(action) { | ||
var chat = action.chat; | ||
var socket = action.socket; | ||
var chat = action.chat, | ||
socket = action.socket; | ||
@@ -240,2 +244,5 @@ socket.emit('accept', (0, _selectors2.isSystemAcceptingCustomers)(store.getState())); | ||
var operator = (0, _selectors.getChatOperator)(chat.id, state); | ||
store.dispatch((0, _reduxDelayedDispatch.cancelAction)((0, _actions.customerLeft)(chat.id))); | ||
store.dispatch((0, _reduxDelayedDispatch.cancelAction)((0, _actions.autocloseChat)(chat.id))); | ||
if (operator && !(0, _ramda.isEmpty)(operator) && status === _reducer.STATUS_CUSTOMER_DISCONNECT) { | ||
@@ -267,17 +274,16 @@ store.dispatch((0, _actions.setChatOperator)(chat.id, operator)); | ||
} | ||
debug('Delaying customer left', customerDisconnectMessageTimeout); | ||
store.dispatch((0, _actions.setChatCustomerDisconnect)(chat.id)); | ||
setTimeout(function () { | ||
var status = (0, _selectors.getChatStatus)(chat.id, store.getState()); | ||
if (status !== _reducer.STATUS_CUSTOMER_DISCONNECT) { | ||
return; | ||
} | ||
store.dispatch((0, _reduxDelayedDispatch.delayAction)((0, _actions.customerLeft)(chat.id), customerDisconnectMessageTimeout)); | ||
store.dispatch((0, _reduxDelayedDispatch.delayAction)((0, _actions.autocloseChat)(chat.id), customerDisconnectTimeout)); | ||
}; | ||
var operator = (0, _selectors.getChatOperator)(chat.id, store.getState()); | ||
store.dispatch((0, _actions.operatorInboundMessage)(chat.id, operator, (0, _ramda.merge)((0, _util.makeEventMessage)('customer left', chat.id), { meta: { event_type: 'customer-leave' } }))); | ||
}, customerDisconnectTimeout); | ||
var handleCustomerLeft = function handleCustomerLeft(action) { | ||
var operator = (0, _selectors.getChatOperator)(action.id, store.getState()); | ||
store.dispatch((0, _actions.operatorInboundMessage)(action.id, operator, (0, _ramda.merge)((0, _util.makeEventMessage)('customer left', action.id), { meta: { event_type: 'customer-leave' } }))); | ||
}; | ||
var handleOperatorReady = function handleOperatorReady(_ref7) { | ||
var user = _ref7.user; | ||
var socket = _ref7.socket; | ||
var user = _ref7.user, | ||
socket = _ref7.socket; | ||
@@ -346,5 +352,20 @@ store.dispatch((0, _actions.recoverChats)(user, socket)); | ||
var handleAutocloseChat = function handleAutocloseChat(action) { | ||
var chat = (0, _selectors.getChat)(action.id, store.getState()); | ||
if (!chat) { | ||
debug('autoclose chat that does not exist'); | ||
chat = { id: action.id }; | ||
} | ||
operator_io.to((0, _index.customerRoom)(chat.id)).emit('chat.close', chat, {}); | ||
store.dispatch((0, _actions.operatorInboundMessage)(chat.id, {}, (0, _ramda.merge)((0, _util.makeEventMessage)('chat closed after customer left', chat.id), { meta: { event_type: 'close' } }))); | ||
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); | ||
}); | ||
}; | ||
var handleCloseChat = function handleCloseChat(action) { | ||
var chat_id = action.chat_id; | ||
var operator = action.operator; | ||
var chat_id = action.chat_id, | ||
operator = action.operator; | ||
@@ -366,4 +387,4 @@ var chat = (0, _selectors.getChat)(chat_id, store.getState()); | ||
var handleSetChatOperator = function handleSetChatOperator(action) { | ||
var operator = action.operator; | ||
var chat_id = action.chat_id; | ||
var operator = action.operator, | ||
chat_id = action.chat_id; | ||
@@ -376,5 +397,5 @@ var chat = (0, _selectors.getChat)(action.chat_id, store.getState()); | ||
debug('time to do the transfer dance', action, store.getState()); | ||
var chat_id = action.chat_id; | ||
var toUser = action.toUser; | ||
var user = action.user; | ||
var chat_id = action.chat_id, | ||
toUser = action.toUser, | ||
user = action.user; | ||
@@ -409,8 +430,6 @@ var chat = (0, _selectors.getChat)(chat_id, store.getState()); | ||
var _list = _toArray(list); | ||
var _list = _toArray(list), | ||
next = _list[0], | ||
rest = _list.slice(1); | ||
var next = _list[0]; | ||
var rest = _list.slice(1); | ||
// TODO: timeout? | ||
@@ -430,3 +449,3 @@ | ||
debug('reassign', operator.id); | ||
var chats = (0, _selectors.getChatsForOperator)(operator.id, store.getState()); | ||
var chats = (0, _selectors.getOpenChatsForOperator)(operator.id, store.getState()); | ||
debug('reassign existing chants to operator', operator.id); | ||
@@ -547,2 +566,8 @@ Promise.all((0, _ramda.map)(function (chat) { | ||
break; | ||
case _actions.CUSTOMER_LEFT: | ||
handleCustomerLeft(action); | ||
break; | ||
case _actions.AUTOCLOSE_CHAT: | ||
handleAutocloseChat(action); | ||
break; | ||
} | ||
@@ -549,0 +574,0 @@ var result = next(action); |
@@ -93,7 +93,7 @@ 'use strict'; | ||
var formatAgentMessage = function formatAgentMessage(author_type, author_id, session_id, _ref) { | ||
var id = _ref.id; | ||
var timestamp = _ref.timestamp; | ||
var text = _ref.text; | ||
var meta = _ref.meta; | ||
var type = _ref.type; | ||
var id = _ref.id, | ||
timestamp = _ref.timestamp, | ||
text = _ref.text, | ||
meta = _ref.meta, | ||
type = _ref.type; | ||
return { | ||
@@ -114,7 +114,7 @@ id: id, timestamp: timestamp, text: text, | ||
var runMiddleware = function runMiddleware(_ref2) { | ||
var origin = _ref2.origin; | ||
var destination = _ref2.destination; | ||
var chat = _ref2.chat; | ||
var user = _ref2.user; | ||
var message = _ref2.message; | ||
var origin = _ref2.origin, | ||
destination = _ref2.destination, | ||
chat = _ref2.chat, | ||
user = _ref2.user, | ||
message = _ref2.message; | ||
return new Promise(function (resolveMiddleware) { | ||
@@ -132,8 +132,6 @@ new Promise(function (middlewareComplete) { | ||
var run = function run(data, _ref3) { | ||
var _ref4 = _toArray(_ref3); | ||
var _ref4 = _toArray(_ref3), | ||
head = _ref4[0], | ||
rest = _ref4.slice(1); | ||
var head = _ref4[0]; | ||
var rest = _ref4.slice(1); | ||
if (!head) { | ||
@@ -174,5 +172,5 @@ debug('middleware complete', chat.id, data.type); | ||
var handleCustomerJoin = function handleCustomerJoin(action) { | ||
var user = action.user; | ||
var socket = action.socket; | ||
var chat = action.chat; | ||
var user = action.user, | ||
socket = action.socket, | ||
chat = action.chat; | ||
@@ -186,5 +184,5 @@ log.customer.findLog(chat.id).then(function (messages) { | ||
var handleOperatorJoin = function handleOperatorJoin(action) { | ||
var chat = action.chat; | ||
var operator = action.user; | ||
var socket = action.socket; | ||
var chat = action.chat, | ||
operator = action.user, | ||
socket = action.socket; | ||
@@ -198,5 +196,5 @@ debug('emitting chat log to operator', operator.id); | ||
var handleCustomerTyping = function handleCustomerTyping(action) { | ||
var id = action.id; | ||
var user = action.user; | ||
var text = action.text; | ||
var id = action.id, | ||
user = action.user, | ||
text = action.text; | ||
@@ -207,5 +205,5 @@ store.dispatch((0, _actions.operatorReceiveTyping)(id, user, text)); | ||
var handleOperatorTyping = function handleOperatorTyping(action) { | ||
var id = action.id; | ||
var user = action.user; | ||
var text = action.text; | ||
var id = action.id, | ||
user = action.user, | ||
text = action.text; | ||
@@ -217,4 +215,4 @@ store.dispatch((0, _actions.operatorReceiveTyping)(id, user, text)); | ||
var handleCustomerInboundMessage = function handleCustomerInboundMessage(action) { | ||
var chat = action.chat; | ||
var message = action.message; | ||
var chat = action.chat, | ||
message = action.message; | ||
// broadcast the message to | ||
@@ -258,5 +256,5 @@ | ||
var handleOperatorInboundMessage = function handleOperatorInboundMessage(action) { | ||
var chat_id = action.chat_id; | ||
var operator = action.user; | ||
var message = action.message; | ||
var chat_id = action.chat_id, | ||
operator = action.user, | ||
message = action.message; | ||
// TODO: look up chat from store? | ||
@@ -263,0 +261,0 @@ |
@@ -21,5 +21,5 @@ 'use strict'; | ||
var identityForUser = function identityForUser(_ref) { | ||
var id = _ref.id; | ||
var displayName = _ref.displayName; | ||
var avatarURL = _ref.avatarURL; | ||
var id = _ref.id, | ||
displayName = _ref.displayName, | ||
avatarURL = _ref.avatarURL; | ||
return { id: id, displayName: displayName, avatarURL: avatarURL }; | ||
@@ -36,6 +36,6 @@ }; | ||
var join = function join(_ref2) { | ||
var socket = _ref2.socket; | ||
var store = _ref2.store; | ||
var user = _ref2.user; | ||
var io = _ref2.io; | ||
var socket = _ref2.socket, | ||
store = _ref2.store, | ||
user = _ref2.user, | ||
io = _ref2.io; | ||
@@ -81,4 +81,4 @@ debug('initialize the operator', user); | ||
socket.on('message', function (chat_id, _ref3) { | ||
var id = _ref3.id; | ||
var text = _ref3.text; | ||
var id = _ref3.id, | ||
text = _ref3.text; | ||
@@ -85,0 +85,0 @@ var meta = {}; |
@@ -34,4 +34,4 @@ 'use strict'; | ||
var handleSetUserLoads = function handleSetUserLoads(_ref, next, action) { | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState; | ||
var dispatch = _ref.dispatch, | ||
getState = _ref.getState; | ||
@@ -46,4 +46,4 @@ var result = next(action); | ||
var notifySystemStatus = function notifySystemStatus(_ref2) { | ||
var getState = _ref2.getState; | ||
var dispatch = _ref2.dispatch; | ||
var getState = _ref2.getState, | ||
dispatch = _ref2.dispatch; | ||
return function (next) { | ||
@@ -63,4 +63,4 @@ return function (action) { | ||
var updateLoadMiddleware = function updateLoadMiddleware(_ref3) { | ||
var getState = _ref3.getState; | ||
var dispatch = _ref3.dispatch; | ||
var getState = _ref3.getState, | ||
dispatch = _ref3.dispatch; | ||
return function (next) { | ||
@@ -109,4 +109,4 @@ return function (action) { | ||
var chatStatusNotifier = function chatStatusNotifier(_ref4) { | ||
var getState = _ref4.getState; | ||
var dispatch = _ref4.dispatch; | ||
var getState = _ref4.getState, | ||
dispatch = _ref4.dispatch; | ||
return function (next) { | ||
@@ -157,2 +157,13 @@ return function (action) { | ||
exports.default = [updateLoadMiddleware, notifySystemStatus, chatStatusNotifier]; | ||
// when a chat is disconnected | ||
var chatDisconnectMonitor = function chatDisconnectMonitor(_ref5) { | ||
var getState = _ref5.getState, | ||
dispatch = _ref5.dispatch; | ||
return function (next) { | ||
return function (action) { | ||
return next(action); | ||
}; | ||
}; | ||
}; | ||
exports.default = [updateLoadMiddleware, notifySystemStatus, chatStatusNotifier, chatDisconnectMonitor]; |
@@ -10,4 +10,4 @@ 'use strict'; | ||
exports.default = function (_ref) { | ||
var action = _ref.action; | ||
var user = _ref.user; | ||
var action = _ref.action, | ||
user = _ref.user; | ||
@@ -14,0 +14,0 @@ if (!user) { |
@@ -49,4 +49,4 @@ 'use strict'; | ||
var action = arguments[1]; | ||
var user = action.user; | ||
var socket = action.socket; | ||
var user = action.user, | ||
socket = action.socket; | ||
@@ -131,4 +131,4 @@ switch (action.type) { | ||
var action = arguments[1]; | ||
var user = action.user; | ||
var socket = action.socket; | ||
var user = action.user, | ||
socket = action.socket; | ||
@@ -135,0 +135,0 @@ switch (action.type) { |
@@ -25,4 +25,4 @@ 'use strict'; | ||
var weight = function weight(_ref) { | ||
var load = _ref.load; | ||
var capacity = _ref.capacity; | ||
var load = _ref.load, | ||
capacity = _ref.capacity; | ||
return (capacity - load) / capacity; | ||
@@ -42,6 +42,6 @@ }; | ||
}), (0, _ramda.filter)(function (_ref2) { | ||
var status = _ref2.status; | ||
var load = _ref2.load; | ||
var capacity = _ref2.capacity; | ||
var online = _ref2.online; | ||
var status = _ref2.status, | ||
load = _ref2.load, | ||
capacity = _ref2.capacity, | ||
online = _ref2.online; | ||
@@ -60,5 +60,5 @@ if (!online || status !== _socketIo.STATUS_AVAILABLE) { | ||
var selectSocketIdentity = exports.selectSocketIdentity = function selectSocketIdentity(_ref4, socket) { | ||
var _ref4$operators = _ref4.operators; | ||
var sockets = _ref4$operators.sockets; | ||
var identities = _ref4$operators.identities; | ||
var _ref4$operators = _ref4.operators, | ||
sockets = _ref4$operators.sockets, | ||
identities = _ref4$operators.identities; | ||
return (0, _get2.default)(identities, (0, _get2.default)(sockets, socket.id)); | ||
@@ -74,7 +74,7 @@ }; | ||
return (0, _reduce2.default)(identities, function (_ref7, _ref8) { | ||
var totalLoad = _ref7.load; | ||
var totalCapacity = _ref7.capacity; | ||
var load = _ref8.load; | ||
var capacity = _ref8.capacity; | ||
var status = _ref8.status; | ||
var totalLoad = _ref7.load, | ||
totalCapacity = _ref7.capacity; | ||
var load = _ref8.load, | ||
capacity = _ref8.capacity, | ||
status = _ref8.status; | ||
return { | ||
@@ -88,7 +88,6 @@ load: totalLoad + (status === matchingStatus ? parseInt(load) : 0), | ||
var getAvailableCapacity = exports.getAvailableCapacity = function getAvailableCapacity(state) { | ||
var _selectTotalCapacity = selectTotalCapacity(state); | ||
var _selectTotalCapacity = selectTotalCapacity(state), | ||
load = _selectTotalCapacity.load, | ||
capacity = _selectTotalCapacity.capacity; | ||
var load = _selectTotalCapacity.load; | ||
var capacity = _selectTotalCapacity.capacity; | ||
return capacity - load; | ||
@@ -95,0 +94,0 @@ }; |
@@ -37,5 +37,5 @@ 'use strict'; | ||
var service = exports.service = function service(server, _ref, state) { | ||
var customerAuthenticator = _ref.customerAuthenticator; | ||
var agentAuthenticator = _ref.agentAuthenticator; | ||
var operatorAuthenticator = _ref.operatorAuthenticator; | ||
var customerAuthenticator = _ref.customerAuthenticator, | ||
agentAuthenticator = _ref.agentAuthenticator, | ||
operatorAuthenticator = _ref.operatorAuthenticator; | ||
@@ -42,0 +42,0 @@ debug('configuring socket.io server'); |
@@ -8,2 +8,6 @@ 'use strict'; | ||
var _reduxDelayedDispatch = require('redux-delayed-dispatch'); | ||
var _reduxDelayedDispatch2 = _interopRequireDefault(_reduxDelayedDispatch); | ||
var _redux = require('redux'); | ||
@@ -77,14 +81,14 @@ | ||
exports.default = function (_ref2, state, reducer) { | ||
var io = _ref2.io; | ||
var customerAuth = _ref2.customerAuth; | ||
var operatorAuth = _ref2.operatorAuth; | ||
var agentAuth = _ref2.agentAuth; | ||
var _ref2$messageMiddlewa = _ref2.messageMiddlewares; | ||
var messageMiddlewares = _ref2$messageMiddlewa === undefined ? [] : _ref2$messageMiddlewa; | ||
var _ref2$middlewares = _ref2.middlewares; | ||
var middlewares = _ref2$middlewares === undefined ? [] : _ref2$middlewares; | ||
var _ref2$timeout = _ref2.timeout; | ||
var timeout = _ref2$timeout === undefined ? undefined : _ref2$timeout; | ||
var io = _ref2.io, | ||
customerAuth = _ref2.customerAuth, | ||
operatorAuth = _ref2.operatorAuth, | ||
agentAuth = _ref2.agentAuth, | ||
_ref2$messageMiddlewa = _ref2.messageMiddlewares, | ||
messageMiddlewares = _ref2$messageMiddlewa === undefined ? [] : _ref2$messageMiddlewa, | ||
_ref2$middlewares = _ref2.middlewares, | ||
middlewares = _ref2$middlewares === undefined ? [] : _ref2$middlewares, | ||
_ref2$timeout = _ref2.timeout, | ||
timeout = _ref2$timeout === undefined ? undefined : _ref2$timeout; | ||
return (0, _redux.createStore)(reducer, state, _redux.applyMiddleware.apply(undefined, [logger].concat(_toConsumableArray(middlewares), [(0, _controller2.default)(messageMiddlewares), (0, _socketIo2.default)(io.of('/operator'), operatorAuth), (0, _agents2.default)(io.of('/agent'), agentAuth), (0, _chatlist2.default)({ io: io, timeout: timeout, customerDisconnectTimeout: timeout }, customerAuth), (0, _broadcast2.default)(io.of('/operator'), _canRemoteDispatch2.default)], _toConsumableArray(_operatorLoad2.default)))); | ||
return (0, _redux.createStore)(reducer, state, _redux.applyMiddleware.apply(undefined, [logger].concat(_toConsumableArray(middlewares), [_reduxDelayedDispatch2.default, (0, _controller2.default)(messageMiddlewares), (0, _socketIo2.default)(io.of('/operator'), operatorAuth), (0, _agents2.default)(io.of('/agent'), agentAuth), (0, _chatlist2.default)({ io: io, timeout: timeout, customerDisconnectTimeout: timeout, customerDisconnectMessageTimeout: timeout }, customerAuth), (0, _broadcast2.default)(io.of('/operator'), _canRemoteDispatch2.default)], _toConsumableArray(_operatorLoad2.default)))); | ||
}; |
{ | ||
"name": "happychat-service", | ||
"version": "0.10.8-2", | ||
"version": "0.10.8-3", | ||
"description": "Socket.IO based chat server for happychat.", | ||
@@ -24,5 +24,6 @@ "main": "index.js", | ||
"devDependencies": { | ||
"babel-cli": "^6.5.2", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-register": "^6.7.0", | ||
"babel-cli": "^6.18.0", | ||
"babel-core": "^6.18.2", | ||
"babel-preset-es2015": "^6.18.0", | ||
"babel-register": "^6.18.0", | ||
"isparta": "^4.0.0", | ||
@@ -38,2 +39,3 @@ "mocha": "^2.4.5", | ||
"redux": "^3.5.2", | ||
"redux-delayed-dispatch": "^1.0.0-2", | ||
"simperium-jsondiff": "^1.0.1-1", | ||
@@ -40,0 +42,0 @@ "socket.io": "^1.4.5", |
93583
2133
8
8
+ Addedredux-delayed-dispatch@1.0.0-2(transitive)