5724a52107831cfc2a637661f6a55ad3b1ddb45b
[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 _0xee6d=['paused','available','loggedIn','stringify','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','map','Agents','_rr','length','online','mailPause'];(function(_0xba44ea,_0x59fe7d){var _0x565459=function(_0x582f93){while(--_0x582f93){_0xba44ea['push'](_0xba44ea['shift']());}};_0x565459(++_0x59fe7d);}(_0xee6d,0x19b));var _0xdee6=function(_0x55b7b0,_0x2df366){_0x55b7b0=_0x55b7b0-0x0;var _0x231f56=_0xee6d[_0x55b7b0];return _0x231f56;};'use strict';var _=require(_0xdee6('0x0'));var md5=require(_0xdee6('0x1'));var util=require(_0xdee6('0x2'));var Redis=require(_0xdee6('0x3'));var config=require(_0xdee6('0x4'));config[_0xdee6('0x5')]=_['defaults'](config[_0xdee6('0x5')],{'host':_0xdee6('0x6'),'port':0x18eb});var io=require(_0xdee6('0x7'))(new Redis(config['redis']));function MailQueue(_0x5e08d2){this['id']=_0x5e08d2['id']||0x0;this['name']=_0x5e08d2[_0xdee6('0x8')]||'';this[_0xdee6('0x9')]=_0x5e08d2[_0xdee6('0x9')]||0xa;this[_0xdee6('0xa')]=_0x5e08d2['strategy']||_0xdee6('0xb');this['Agents']=_0x5e08d2['Agents'];this[_0xdee6('0xc')]={};this[_0xdee6('0xd')]=0x0;this[_0xdee6('0x1')]='';this[_0xdee6('0xe')]();this[_0xdee6('0xf')]();}MailQueue[_0xdee6('0x10')][_0xdee6('0xe')]=function(){var _0xe527dc=this['mapAgentsId']['_rr'];this[_0xdee6('0xc')]=_[_0xdee6('0x11')](this[_0xdee6('0x12')],'id');this[_0xdee6('0xc')][_0xdee6('0x13')]=_0xe527dc;};MailQueue[_0xdee6('0x10')][_0xdee6('0xf')]=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x2851e0=0x0;_0x2851e0<this[_0xdee6('0x12')][_0xdee6('0x14')];_0x2851e0+=0x1){if(this[_0xdee6('0x12')][_0x2851e0][_0xdee6('0x15')]){this['loggedIn']+=0x1;}if(this[_0xdee6('0x12')][_0x2851e0][_0xdee6('0x16')]){this[_0xdee6('0x17')]+=0x1;}}this['available']=this['loggedIn']-this[_0xdee6('0x17')];this[_0xdee6('0x18')]=this[_0xdee6('0x18')]>=0x0?this[_0xdee6('0x18')]:0x0;var _0x257cad={'id':this['id'],'available':this['available'],'loggedIn':this[_0xdee6('0x19')],'name':this['name'],'paused':this[_0xdee6('0x17')],'waiting':this[_0xdee6('0xd')]};var _0x52a912=md5(JSON[_0xdee6('0x1a')](_0x257cad));if(this[_0xdee6('0x1')]!==_0x52a912){this[_0xdee6('0x1')]=_0x52a912;io['to'](util['format'](_0xdee6('0x1b'),_0x257cad[_0xdee6('0x8')]))[_0xdee6('0x1c')](_0xdee6('0x1d'),_0x257cad);}};module[_0xdee6('0x1e')]=MailQueue;