Built motion from commit (unavailable).|2.3.91
[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 _0x4ab5=['_rr','paused','length','online','chatPause','available','format','chat:queue:%s','chat_queue:save','exports','lodash','md5','util','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','prototype'];(function(_0x100682,_0x11afec){var _0xcb6e87=function(_0x3ef421){while(--_0x3ef421){_0x100682['push'](_0x100682['shift']());}};_0xcb6e87(++_0x11afec);}(_0x4ab5,0x1cc));var _0x54ab=function(_0x486008,_0x2b2d05){_0x486008=_0x486008-0x0;var _0x2fefc7=_0x4ab5[_0x486008];return _0x2fefc7;};'use strict';var _=require(_0x54ab('0x0'));var md5=require(_0x54ab('0x1'));var util=require(_0x54ab('0x2'));var Redis=require('ioredis');var config=require(_0x54ab('0x3'));config[_0x54ab('0x4')]=_[_0x54ab('0x5')](config[_0x54ab('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x54ab('0x6'))(new Redis(config['redis']));function ChatQueue(_0x39b57b){this['id']=_0x39b57b['id']||0x0;this[_0x54ab('0x7')]=_0x39b57b[_0x54ab('0x7')]||'';this['timeout']=_0x39b57b[_0x54ab('0x8')]||0xa;this[_0x54ab('0x9')]=_0x39b57b[_0x54ab('0x9')]||_0x54ab('0xa');this['Agents']=_0x39b57b[_0x54ab('0xb')];this[_0x54ab('0xc')]={};this['waiting']=0x0;this['md5']='';this[_0x54ab('0xd')]();this['updateRealtime']();}ChatQueue[_0x54ab('0xe')][_0x54ab('0xd')]=function(){var _0x5c2862=this['mapAgentsId'][_0x54ab('0xf')];this[_0x54ab('0xc')]=_['map'](this[_0x54ab('0xb')],'id');this[_0x54ab('0xc')][_0x54ab('0xf')]=_0x5c2862;};ChatQueue[_0x54ab('0xe')]['updateRealtime']=function(){this['loggedIn']=0x0;this[_0x54ab('0x10')]=0x0;for(var _0x32a655=0x0;_0x32a655<this['Agents'][_0x54ab('0x11')];_0x32a655+=0x1){if(this[_0x54ab('0xb')][_0x32a655][_0x54ab('0x12')]){this['loggedIn']+=0x1;}if(this[_0x54ab('0xb')][_0x32a655][_0x54ab('0x13')]){this['paused']+=0x1;}}this[_0x54ab('0x14')]=this['loggedIn']-this[_0x54ab('0x10')];this[_0x54ab('0x14')]=this['available']>=0x0?this[_0x54ab('0x14')]:0x0;var _0x335bf4={'id':this['id'],'available':this[_0x54ab('0x14')],'loggedIn':this['loggedIn'],'name':this[_0x54ab('0x7')],'paused':this['paused'],'waiting':this['waiting']};var _0x1d3120=md5(JSON['stringify'](_0x335bf4));if(this[_0x54ab('0x1')]!==_0x1d3120){this['md5']=_0x1d3120;io['to'](util[_0x54ab('0x15')](_0x54ab('0x16'),_0x335bf4['name']))['emit'](_0x54ab('0x17'),_0x335bf4);}};module[_0x54ab('0x18')]=ChatQueue;