Built motion from commit (unavailable).|2.3.4
[motion2.git] / server / services / routing / model / mailQueue.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 _0xf31b=['../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','online','mailPause','available','format','mail:queue:%s','mail_queue:save','lodash','md5','util','ioredis'];(function(_0x215929,_0x514e2a){var _0x3ef31a=function(_0x1121ad){while(--_0x1121ad){_0x215929['push'](_0x215929['shift']());}};_0x3ef31a(++_0x514e2a);}(_0xf31b,0x1a0));var _0xbf31=function(_0x202b91,_0x1d1618){_0x202b91=_0x202b91-0x0;var _0x545ccd=_0xf31b[_0x202b91];return _0x545ccd;};'use strict';var _=require(_0xbf31('0x0'));var md5=require(_0xbf31('0x1'));var util=require(_0xbf31('0x2'));var Redis=require(_0xbf31('0x3'));var config=require(_0xbf31('0x4'));config[_0xbf31('0x5')]=_[_0xbf31('0x6')](config['redis'],{'host':_0xbf31('0x7'),'port':0x18eb});var io=require(_0xbf31('0x8'))(new Redis(config['redis']));function MailQueue(_0x47a5cf){this['id']=_0x47a5cf['id']||0x0;this[_0xbf31('0x9')]=_0x47a5cf['name']||'';this[_0xbf31('0xa')]=_0x47a5cf[_0xbf31('0xa')]||0xa;this['strategy']=_0x47a5cf['strategy']||_0xbf31('0xb');this['Agents']=_0x47a5cf[_0xbf31('0xc')];this[_0xbf31('0xd')]={};this[_0xbf31('0xe')]=0x0;this[_0xbf31('0x1')]='';this[_0xbf31('0xf')]();this[_0xbf31('0x10')]();}MailQueue[_0xbf31('0x11')][_0xbf31('0xf')]=function(){var _0x363d23=this[_0xbf31('0xd')][_0xbf31('0x12')];this[_0xbf31('0xd')]=_[_0xbf31('0x13')](this['Agents'],'id');this['mapAgentsId']['_rr']=_0x363d23;};MailQueue['prototype'][_0xbf31('0x10')]=function(){this[_0xbf31('0x14')]=0x0;this[_0xbf31('0x15')]=0x0;for(var _0x15520a=0x0;_0x15520a<this['Agents']['length'];_0x15520a+=0x1){if(this[_0xbf31('0xc')][_0x15520a][_0xbf31('0x16')]){this[_0xbf31('0x14')]+=0x1;}if(this[_0xbf31('0xc')][_0x15520a][_0xbf31('0x17')]){this['paused']+=0x1;}}this[_0xbf31('0x18')]=this['loggedIn']-this['paused'];this[_0xbf31('0x18')]=this[_0xbf31('0x18')]>=0x0?this[_0xbf31('0x18')]:0x0;var _0x1101e4={'id':this['id'],'available':this[_0xbf31('0x18')],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this[_0xbf31('0x15')],'waiting':this[_0xbf31('0xe')]};var _0x150340=md5(JSON['stringify'](_0x1101e4));if(this[_0xbf31('0x1')]!==_0x150340){this[_0xbf31('0x1')]=_0x150340;io['to'](util[_0xbf31('0x19')](_0xbf31('0x1a'),_0x1101e4[_0xbf31('0x9')]))['emit'](_0xbf31('0x1b'),_0x1101e4);}};module['exports']=MailQueue;