608b6e2ece2aeaccd81904a0d404a395c6b23867
[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 _0x8ad4=['available','format','emit','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','map','Agents','_rr','paused','length','online','loggedIn','mailPause'];(function(_0x19386a,_0x2f2753){var _0x4ed232=function(_0x32f985){while(--_0x32f985){_0x19386a['push'](_0x19386a['shift']());}};_0x4ed232(++_0x2f2753);}(_0x8ad4,0x126));var _0x48ad=function(_0x53fdf9,_0x16b2fc){_0x53fdf9=_0x53fdf9-0x0;var _0x2d447d=_0x8ad4[_0x53fdf9];return _0x2d447d;};'use strict';var _=require(_0x48ad('0x0'));var md5=require(_0x48ad('0x1'));var util=require(_0x48ad('0x2'));var Redis=require(_0x48ad('0x3'));var config=require(_0x48ad('0x4'));config[_0x48ad('0x5')]=_[_0x48ad('0x6')](config[_0x48ad('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0x48ad('0x7'))(new Redis(config['redis']));function MailQueue(_0x134275){this['id']=_0x134275['id']||0x0;this[_0x48ad('0x8')]=_0x134275[_0x48ad('0x8')]||'';this[_0x48ad('0x9')]=_0x134275[_0x48ad('0x9')]||0xa;this[_0x48ad('0xa')]=_0x134275[_0x48ad('0xa')]||_0x48ad('0xb');this['Agents']=_0x134275['Agents'];this[_0x48ad('0xc')]={};this[_0x48ad('0xd')]=0x0;this['md5']='';this[_0x48ad('0xe')]();this[_0x48ad('0xf')]();}MailQueue[_0x48ad('0x10')][_0x48ad('0xe')]=function(){var _0x543894=this[_0x48ad('0xc')]['_rr'];this[_0x48ad('0xc')]=_[_0x48ad('0x11')](this[_0x48ad('0x12')],'id');this[_0x48ad('0xc')][_0x48ad('0x13')]=_0x543894;};MailQueue[_0x48ad('0x10')]['updateRealtime']=function(){this['loggedIn']=0x0;this[_0x48ad('0x14')]=0x0;for(var _0x5e776d=0x0;_0x5e776d<this[_0x48ad('0x12')][_0x48ad('0x15')];_0x5e776d+=0x1){if(this[_0x48ad('0x12')][_0x5e776d][_0x48ad('0x16')]){this[_0x48ad('0x17')]+=0x1;}if(this[_0x48ad('0x12')][_0x5e776d][_0x48ad('0x18')]){this['paused']+=0x1;}}this['available']=this['loggedIn']-this['paused'];this['available']=this['available']>=0x0?this[_0x48ad('0x19')]:0x0;var _0x471aa2={'id':this['id'],'available':this[_0x48ad('0x19')],'loggedIn':this[_0x48ad('0x17')],'name':this[_0x48ad('0x8')],'paused':this[_0x48ad('0x14')],'waiting':this[_0x48ad('0xd')]};var _0x3b3c5f=md5(JSON['stringify'](_0x471aa2));if(this[_0x48ad('0x1')]!==_0x3b3c5f){this[_0x48ad('0x1')]=_0x3b3c5f;io['to'](util[_0x48ad('0x1a')]('mail:queue:%s',_0x471aa2[_0x48ad('0x8')]))[_0x48ad('0x1b')]('mail_queue:save',_0x471aa2);}};module[_0x48ad('0x1c')]=MailQueue;