Built motion from commit 52c8a02d.|2.6.29
[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 _0x9ce2=['beepall','Agents','waiting','updateRealtime','prototype','updateRouting','mapAgentsId','map','_rr','loggedIn','paused','length','online','available','format','emit','chat_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy'];(function(_0x15e19b,_0x5edeb2){var _0x2e14b1=function(_0x4f618b){while(--_0x4f618b){_0x15e19b['push'](_0x15e19b['shift']());}};_0x2e14b1(++_0x5edeb2);}(_0x9ce2,0x17a));var _0x29ce=function(_0x598b6f,_0x55690f){_0x598b6f=_0x598b6f-0x0;var _0x40959f=_0x9ce2[_0x598b6f];return _0x40959f;};'use strict';var _=require(_0x29ce('0x0'));var md5=require(_0x29ce('0x1'));var util=require(_0x29ce('0x2'));var Redis=require(_0x29ce('0x3'));var config=require(_0x29ce('0x4'));config[_0x29ce('0x5')]=_[_0x29ce('0x6')](config[_0x29ce('0x5')],{'host':_0x29ce('0x7'),'port':0x18eb});var io=require(_0x29ce('0x8'))(new Redis(config[_0x29ce('0x5')]));function ChatQueue(_0x5070e1){this['id']=_0x5070e1['id']||0x0;this[_0x29ce('0x9')]=_0x5070e1['name']||'';this[_0x29ce('0xa')]=_0x5070e1[_0x29ce('0xa')]||0xa;this[_0x29ce('0xb')]=_0x5070e1[_0x29ce('0xb')]||_0x29ce('0xc');this[_0x29ce('0xd')]=_0x5070e1[_0x29ce('0xd')];this['mapAgentsId']={};this[_0x29ce('0xe')]=0x0;this[_0x29ce('0x1')]='';this['updateRouting']();this[_0x29ce('0xf')]();}ChatQueue[_0x29ce('0x10')][_0x29ce('0x11')]=function(){var _0x467d40=this['mapAgentsId']['_rr'];this[_0x29ce('0x12')]=_[_0x29ce('0x13')](this[_0x29ce('0xd')],'id');this[_0x29ce('0x12')][_0x29ce('0x14')]=_0x467d40;};ChatQueue[_0x29ce('0x10')][_0x29ce('0xf')]=function(){this[_0x29ce('0x15')]=0x0;this[_0x29ce('0x16')]=0x0;for(var _0x36ffa4=0x0;_0x36ffa4<this['Agents'][_0x29ce('0x17')];_0x36ffa4+=0x1){if(this[_0x29ce('0xd')][_0x36ffa4][_0x29ce('0x18')]){this[_0x29ce('0x15')]+=0x1;}if(this[_0x29ce('0xd')][_0x36ffa4]['chatPause']){this['paused']+=0x1;}}this[_0x29ce('0x19')]=this[_0x29ce('0x15')]-this[_0x29ce('0x16')];this[_0x29ce('0x19')]=this['available']>=0x0?this[_0x29ce('0x19')]:0x0;var _0x15bec1={'id':this['id'],'available':this[_0x29ce('0x19')],'loggedIn':this['loggedIn'],'name':this[_0x29ce('0x9')],'paused':this[_0x29ce('0x16')],'waiting':this[_0x29ce('0xe')]};var _0x271a56=md5(JSON['stringify'](_0x15bec1));if(this[_0x29ce('0x1')]!==_0x271a56){this['md5']=_0x271a56;io['to'](util[_0x29ce('0x1a')]('chat:queue:%s',_0x15bec1['name']))[_0x29ce('0x1b')](_0x29ce('0x1c'),_0x15bec1);}};module[_0x29ce('0x1d')]=ChatQueue;