Built motion from commit (unavailable).|2.5.31
[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 _0xc61f=['stringify','chat:queue:%s','emit','chat_queue:save','lodash','md5','util','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','map','prototype','paused','length','loggedIn','chatPause','available'];(function(_0x34d4a7,_0x5f3141){var _0xe4f5ef=function(_0xfa5c5a){while(--_0xfa5c5a){_0x34d4a7['push'](_0x34d4a7['shift']());}};_0xe4f5ef(++_0x5f3141);}(_0xc61f,0x156));var _0xfc61=function(_0x409b94,_0x3fd30b){_0x409b94=_0x409b94-0x0;var _0x4538c6=_0xc61f[_0x409b94];return _0x4538c6;};'use strict';var _=require(_0xfc61('0x0'));var md5=require(_0xfc61('0x1'));var util=require(_0xfc61('0x2'));var Redis=require('ioredis');var config=require(_0xfc61('0x3'));config[_0xfc61('0x4')]=_['defaults'](config[_0xfc61('0x4')],{'host':_0xfc61('0x5'),'port':0x18eb});var io=require(_0xfc61('0x6'))(new Redis(config[_0xfc61('0x4')]));function ChatQueue(_0xc65740){this['id']=_0xc65740['id']||0x0;this[_0xfc61('0x7')]=_0xc65740[_0xfc61('0x7')]||'';this[_0xfc61('0x8')]=_0xc65740[_0xfc61('0x8')]||0xa;this[_0xfc61('0x9')]=_0xc65740[_0xfc61('0x9')]||'beepall';this[_0xfc61('0xa')]=_0xc65740['Agents'];this[_0xfc61('0xb')]={};this[_0xfc61('0xc')]=0x0;this[_0xfc61('0x1')]='';this[_0xfc61('0xd')]();this[_0xfc61('0xe')]();}ChatQueue['prototype'][_0xfc61('0xd')]=function(){var _0x59c3de=this['mapAgentsId']['_rr'];this[_0xfc61('0xb')]=_[_0xfc61('0xf')](this[_0xfc61('0xa')],'id');this['mapAgentsId']['_rr']=_0x59c3de;};ChatQueue[_0xfc61('0x10')][_0xfc61('0xe')]=function(){this['loggedIn']=0x0;this[_0xfc61('0x11')]=0x0;for(var _0x1bb40e=0x0;_0x1bb40e<this['Agents'][_0xfc61('0x12')];_0x1bb40e+=0x1){if(this[_0xfc61('0xa')][_0x1bb40e]['online']){this[_0xfc61('0x13')]+=0x1;}if(this[_0xfc61('0xa')][_0x1bb40e][_0xfc61('0x14')]){this[_0xfc61('0x11')]+=0x1;}}this[_0xfc61('0x15')]=this['loggedIn']-this[_0xfc61('0x11')];this[_0xfc61('0x15')]=this[_0xfc61('0x15')]>=0x0?this[_0xfc61('0x15')]:0x0;var _0x25cfe9={'id':this['id'],'available':this[_0xfc61('0x15')],'loggedIn':this[_0xfc61('0x13')],'name':this[_0xfc61('0x7')],'paused':this['paused'],'waiting':this[_0xfc61('0xc')]};var _0x20977c=md5(JSON[_0xfc61('0x16')](_0x25cfe9));if(this['md5']!==_0x20977c){this[_0xfc61('0x1')]=_0x20977c;io['to'](util['format'](_0xfc61('0x17'),_0x25cfe9[_0xfc61('0x7')]))[_0xfc61('0x18')](_0xfc61('0x19'),_0x25cfe9);}};module['exports']=ChatQueue;