Built motion from commit (unavailable).|2.3.3
[motion2.git] / server / services / routing / model / chatQueue.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xd7e0=['prototype','_rr','map','updateRealtime','loggedIn','paused','length','online','chatPause','available','stringify','format','emit','chat_queue:save','lodash','md5','util','ioredis','../../../config/environment','localhost','socket.io-emitter','redis','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting'];(function(_0x237e1b,_0xb6c9e2){var _0x47e755=function(_0x426a07){while(--_0x426a07){_0x237e1b['push'](_0x237e1b['shift']());}};_0x47e755(++_0xb6c9e2);}(_0xd7e0,0xa4));var _0x0d7e=function(_0x4e59b3,_0x214b8e){_0x4e59b3=_0x4e59b3-0x0;var _0x1197f8=_0xd7e0[_0x4e59b3];return _0x1197f8;};'use strict';var _=require(_0x0d7e('0x0'));var md5=require(_0x0d7e('0x1'));var util=require(_0x0d7e('0x2'));var Redis=require(_0x0d7e('0x3'));var config=require(_0x0d7e('0x4'));config['redis']=_['defaults'](config['redis'],{'host':_0x0d7e('0x5'),'port':0x18eb});var io=require(_0x0d7e('0x6'))(new Redis(config[_0x0d7e('0x7')]));function ChatQueue(_0x31b67e){this['id']=_0x31b67e['id']||0x0;this[_0x0d7e('0x8')]=_0x31b67e[_0x0d7e('0x8')]||'';this[_0x0d7e('0x9')]=_0x31b67e[_0x0d7e('0x9')]||0xa;this[_0x0d7e('0xa')]=_0x31b67e['strategy']||_0x0d7e('0xb');this[_0x0d7e('0xc')]=_0x31b67e[_0x0d7e('0xc')];this[_0x0d7e('0xd')]={};this[_0x0d7e('0xe')]=0x0;this[_0x0d7e('0x1')]='';this[_0x0d7e('0xf')]();this['updateRealtime']();}ChatQueue[_0x0d7e('0x10')][_0x0d7e('0xf')]=function(){var _0x486734=this[_0x0d7e('0xd')][_0x0d7e('0x11')];this[_0x0d7e('0xd')]=_[_0x0d7e('0x12')](this[_0x0d7e('0xc')],'id');this[_0x0d7e('0xd')][_0x0d7e('0x11')]=_0x486734;};ChatQueue[_0x0d7e('0x10')][_0x0d7e('0x13')]=function(){this[_0x0d7e('0x14')]=0x0;this[_0x0d7e('0x15')]=0x0;for(var _0x4ff671=0x0;_0x4ff671<this['Agents'][_0x0d7e('0x16')];_0x4ff671+=0x1){if(this[_0x0d7e('0xc')][_0x4ff671][_0x0d7e('0x17')]){this[_0x0d7e('0x14')]+=0x1;}if(this[_0x0d7e('0xc')][_0x4ff671][_0x0d7e('0x18')]){this[_0x0d7e('0x15')]+=0x1;}}this[_0x0d7e('0x19')]=this[_0x0d7e('0x14')]-this[_0x0d7e('0x15')];this[_0x0d7e('0x19')]=this['available']>=0x0?this[_0x0d7e('0x19')]:0x0;var _0x43f786={'id':this['id'],'available':this[_0x0d7e('0x19')],'loggedIn':this[_0x0d7e('0x14')],'name':this[_0x0d7e('0x8')],'paused':this[_0x0d7e('0x15')],'waiting':this[_0x0d7e('0xe')]};var _0x1e9d46=md5(JSON[_0x0d7e('0x1a')](_0x43f786));if(this[_0x0d7e('0x1')]!==_0x1e9d46){this[_0x0d7e('0x1')]=_0x1e9d46;io['to'](util[_0x0d7e('0x1b')]('chat:queue:%s',_0x43f786['name']))[_0x0d7e('0x1c')](_0x0d7e('0x1d'),_0x43f786);}};module['exports']=ChatQueue;