Built motion from commit d5e4af8c.|2.6.23
[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 _0xe68c=['timeout','strategy','beepall','Agents','waiting','updateRouting','updateRealtime','prototype','mapAgentsId','_rr','map','loggedIn','paused','online','chatPause','available','stringify','format','chat:queue:%s','emit','exports','lodash','md5','util','ioredis','../../../config/environment','defaults','localhost','socket.io-emitter','name'];(function(_0x14079c,_0x5337b4){var _0xcd69c1=function(_0x4fe8c7){while(--_0x4fe8c7){_0x14079c['push'](_0x14079c['shift']());}};_0xcd69c1(++_0x5337b4);}(_0xe68c,0x123));var _0xce68=function(_0x403f5f,_0x283f67){_0x403f5f=_0x403f5f-0x0;var _0x15b1cd=_0xe68c[_0x403f5f];return _0x15b1cd;};'use strict';var _=require(_0xce68('0x0'));var md5=require(_0xce68('0x1'));var util=require(_0xce68('0x2'));var Redis=require(_0xce68('0x3'));var config=require(_0xce68('0x4'));config['redis']=_[_0xce68('0x5')](config['redis'],{'host':_0xce68('0x6'),'port':0x18eb});var io=require(_0xce68('0x7'))(new Redis(config['redis']));function ChatQueue(_0x54badc){this['id']=_0x54badc['id']||0x0;this['name']=_0x54badc[_0xce68('0x8')]||'';this[_0xce68('0x9')]=_0x54badc['timeout']||0xa;this[_0xce68('0xa')]=_0x54badc[_0xce68('0xa')]||_0xce68('0xb');this['Agents']=_0x54badc[_0xce68('0xc')];this['mapAgentsId']={};this[_0xce68('0xd')]=0x0;this[_0xce68('0x1')]='';this[_0xce68('0xe')]();this[_0xce68('0xf')]();}ChatQueue[_0xce68('0x10')][_0xce68('0xe')]=function(){var _0x28f0ae=this[_0xce68('0x11')][_0xce68('0x12')];this['mapAgentsId']=_[_0xce68('0x13')](this[_0xce68('0xc')],'id');this['mapAgentsId'][_0xce68('0x12')]=_0x28f0ae;};ChatQueue[_0xce68('0x10')]['updateRealtime']=function(){this[_0xce68('0x14')]=0x0;this[_0xce68('0x15')]=0x0;for(var _0x1ff6ed=0x0;_0x1ff6ed<this[_0xce68('0xc')]['length'];_0x1ff6ed+=0x1){if(this['Agents'][_0x1ff6ed][_0xce68('0x16')]){this['loggedIn']+=0x1;}if(this[_0xce68('0xc')][_0x1ff6ed][_0xce68('0x17')]){this[_0xce68('0x15')]+=0x1;}}this[_0xce68('0x18')]=this['loggedIn']-this['paused'];this[_0xce68('0x18')]=this[_0xce68('0x18')]>=0x0?this[_0xce68('0x18')]:0x0;var _0x11397f={'id':this['id'],'available':this[_0xce68('0x18')],'loggedIn':this[_0xce68('0x14')],'name':this[_0xce68('0x8')],'paused':this['paused'],'waiting':this['waiting']};var _0x2d15d4=md5(JSON[_0xce68('0x19')](_0x11397f));if(this[_0xce68('0x1')]!==_0x2d15d4){this[_0xce68('0x1')]=_0x2d15d4;io['to'](util[_0xce68('0x1a')](_0xce68('0x1b'),_0x11397f['name']))[_0xce68('0x1c')]('chat_queue:save',_0x11397f);}};module[_0xce68('0x1d')]=ChatQueue;