c5c6a2c6592a9bbad65709986614c96f17bc4c13
[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 _0x4980=['lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','mapAgentsId','updateRouting','updateRealtime','_rr','Agents','prototype','paused','length','loggedIn','chatPause','available','waiting','stringify','format','chat:queue:%s','emit','chat_queue:save','exports'];(function(_0x21bd12,_0x332b10){var _0x30f84b=function(_0x441793){while(--_0x441793){_0x21bd12['push'](_0x21bd12['shift']());}};_0x30f84b(++_0x332b10);}(_0x4980,0x9b));var _0x0498=function(_0x4aa7da,_0x2523cc){_0x4aa7da=_0x4aa7da-0x0;var _0x164a9c=_0x4980[_0x4aa7da];return _0x164a9c;};'use strict';var _=require(_0x0498('0x0'));var md5=require(_0x0498('0x1'));var util=require(_0x0498('0x2'));var Redis=require(_0x0498('0x3'));var config=require(_0x0498('0x4'));config[_0x0498('0x5')]=_[_0x0498('0x6')](config[_0x0498('0x5')],{'host':_0x0498('0x7'),'port':0x18eb});var io=require(_0x0498('0x8'))(new Redis(config[_0x0498('0x5')]));function ChatQueue(_0x45f456){this['id']=_0x45f456['id']||0x0;this[_0x0498('0x9')]=_0x45f456[_0x0498('0x9')]||'';this[_0x0498('0xa')]=_0x45f456['timeout']||0xa;this[_0x0498('0xb')]=_0x45f456['strategy']||_0x0498('0xc');this['Agents']=_0x45f456['Agents'];this[_0x0498('0xd')]={};this['waiting']=0x0;this[_0x0498('0x1')]='';this[_0x0498('0xe')]();this[_0x0498('0xf')]();}ChatQueue['prototype'][_0x0498('0xe')]=function(){var _0x3312c2=this[_0x0498('0xd')][_0x0498('0x10')];this['mapAgentsId']=_['map'](this[_0x0498('0x11')],'id');this[_0x0498('0xd')]['_rr']=_0x3312c2;};ChatQueue[_0x0498('0x12')][_0x0498('0xf')]=function(){this['loggedIn']=0x0;this[_0x0498('0x13')]=0x0;for(var _0x202aef=0x0;_0x202aef<this[_0x0498('0x11')][_0x0498('0x14')];_0x202aef+=0x1){if(this['Agents'][_0x202aef]['online']){this[_0x0498('0x15')]+=0x1;}if(this[_0x0498('0x11')][_0x202aef][_0x0498('0x16')]){this[_0x0498('0x13')]+=0x1;}}this[_0x0498('0x17')]=this[_0x0498('0x15')]-this[_0x0498('0x13')];this[_0x0498('0x17')]=this[_0x0498('0x17')]>=0x0?this[_0x0498('0x17')]:0x0;var _0x26a290={'id':this['id'],'available':this[_0x0498('0x17')],'loggedIn':this[_0x0498('0x15')],'name':this[_0x0498('0x9')],'paused':this[_0x0498('0x13')],'waiting':this[_0x0498('0x18')]};var _0x4ed1b8=md5(JSON[_0x0498('0x19')](_0x26a290));if(this[_0x0498('0x1')]!==_0x4ed1b8){this['md5']=_0x4ed1b8;io['to'](util[_0x0498('0x1a')](_0x0498('0x1b'),_0x26a290[_0x0498('0x9')]))[_0x0498('0x1c')](_0x0498('0x1d'),_0x26a290);}};module[_0x0498('0x1e')]=ChatQueue;