5bd41235ffdfbae3d04ac1544f0e38d0cb945462
[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 _0x8ea5=['updateRealtime','prototype','map','_rr','loggedIn','paused','length','online','available','stringify','format','mail:queue:%s','emit','mail_queue:save','exports','util','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','beepall','Agents','mapAgentsId','waiting','md5','updateRouting'];(function(_0x36c806,_0x1d3de3){var _0x406023=function(_0x546af8){while(--_0x546af8){_0x36c806['push'](_0x36c806['shift']());}};_0x406023(++_0x1d3de3);}(_0x8ea5,0x188));var _0x58ea=function(_0x2e4686,_0x46705f){_0x2e4686=_0x2e4686-0x0;var _0x9aeded=_0x8ea5[_0x2e4686];return _0x9aeded;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0x58ea('0x0'));var Redis=require('ioredis');var config=require(_0x58ea('0x1'));config[_0x58ea('0x2')]=_[_0x58ea('0x3')](config['redis'],{'host':_0x58ea('0x4'),'port':0x18eb});var io=require(_0x58ea('0x5'))(new Redis(config[_0x58ea('0x2')]));function MailQueue(_0x2e439d){this['id']=_0x2e439d['id']||0x0;this[_0x58ea('0x6')]=_0x2e439d[_0x58ea('0x6')]||'';this['timeout']=_0x2e439d[_0x58ea('0x7')]||0xa;this['strategy']=_0x2e439d['strategy']||_0x58ea('0x8');this[_0x58ea('0x9')]=_0x2e439d['Agents'];this[_0x58ea('0xa')]={};this[_0x58ea('0xb')]=0x0;this[_0x58ea('0xc')]='';this[_0x58ea('0xd')]();this[_0x58ea('0xe')]();}MailQueue[_0x58ea('0xf')][_0x58ea('0xd')]=function(){var _0x145e4b=this[_0x58ea('0xa')]['_rr'];this[_0x58ea('0xa')]=_[_0x58ea('0x10')](this['Agents'],'id');this[_0x58ea('0xa')][_0x58ea('0x11')]=_0x145e4b;};MailQueue['prototype']['updateRealtime']=function(){this[_0x58ea('0x12')]=0x0;this[_0x58ea('0x13')]=0x0;for(var _0x3efbe6=0x0;_0x3efbe6<this[_0x58ea('0x9')][_0x58ea('0x14')];_0x3efbe6+=0x1){if(this[_0x58ea('0x9')][_0x3efbe6][_0x58ea('0x15')]){this[_0x58ea('0x12')]+=0x1;}if(this[_0x58ea('0x9')][_0x3efbe6]['mailPause']){this['paused']+=0x1;}}this[_0x58ea('0x16')]=this[_0x58ea('0x12')]-this[_0x58ea('0x13')];this[_0x58ea('0x16')]=this[_0x58ea('0x16')]>=0x0?this[_0x58ea('0x16')]:0x0;var _0x4f0d85={'id':this['id'],'available':this['available'],'loggedIn':this[_0x58ea('0x12')],'name':this[_0x58ea('0x6')],'paused':this['paused'],'waiting':this['waiting']};var _0x571055=md5(JSON[_0x58ea('0x17')](_0x4f0d85));if(this['md5']!==_0x571055){this[_0x58ea('0xc')]=_0x571055;io['to'](util[_0x58ea('0x18')](_0x58ea('0x19'),_0x4f0d85[_0x58ea('0x6')]))[_0x58ea('0x1a')](_0x58ea('0x1b'),_0x4f0d85);}};module[_0x58ea('0x1c')]=MailQueue;