Built motion from commit 39adb707.|2.6.14
[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 _0xed17=['name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','map','updateRealtime','loggedIn','paused','online','mailPause','available','stringify','format','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','localhost','socket.io-emitter'];(function(_0x3cc931,_0x1d6b62){var _0x47b7fc=function(_0x542c1a){while(--_0x542c1a){_0x3cc931['push'](_0x3cc931['shift']());}};_0x47b7fc(++_0x1d6b62);}(_0xed17,0x93));var _0x7ed1=function(_0x560589,_0x3889f0){_0x560589=_0x560589-0x0;var _0x386054=_0xed17[_0x560589];return _0x386054;};'use strict';var _=require(_0x7ed1('0x0'));var md5=require(_0x7ed1('0x1'));var util=require(_0x7ed1('0x2'));var Redis=require(_0x7ed1('0x3'));var config=require(_0x7ed1('0x4'));config[_0x7ed1('0x5')]=_['defaults'](config[_0x7ed1('0x5')],{'host':_0x7ed1('0x6'),'port':0x18eb});var io=require(_0x7ed1('0x7'))(new Redis(config[_0x7ed1('0x5')]));function MailQueue(_0x499ba7){this['id']=_0x499ba7['id']||0x0;this[_0x7ed1('0x8')]=_0x499ba7['name']||'';this[_0x7ed1('0x9')]=_0x499ba7[_0x7ed1('0x9')]||0xa;this[_0x7ed1('0xa')]=_0x499ba7[_0x7ed1('0xa')]||_0x7ed1('0xb');this[_0x7ed1('0xc')]=_0x499ba7['Agents'];this[_0x7ed1('0xd')]={};this[_0x7ed1('0xe')]=0x0;this[_0x7ed1('0x1')]='';this[_0x7ed1('0xf')]();this['updateRealtime']();}MailQueue[_0x7ed1('0x10')]['updateRouting']=function(){var _0x3cc60a=this['mapAgentsId'][_0x7ed1('0x11')];this[_0x7ed1('0xd')]=_[_0x7ed1('0x12')](this[_0x7ed1('0xc')],'id');this['mapAgentsId']['_rr']=_0x3cc60a;};MailQueue['prototype'][_0x7ed1('0x13')]=function(){this[_0x7ed1('0x14')]=0x0;this[_0x7ed1('0x15')]=0x0;for(var _0x330f48=0x0;_0x330f48<this[_0x7ed1('0xc')]['length'];_0x330f48+=0x1){if(this[_0x7ed1('0xc')][_0x330f48][_0x7ed1('0x16')]){this[_0x7ed1('0x14')]+=0x1;}if(this[_0x7ed1('0xc')][_0x330f48][_0x7ed1('0x17')]){this[_0x7ed1('0x15')]+=0x1;}}this[_0x7ed1('0x18')]=this[_0x7ed1('0x14')]-this[_0x7ed1('0x15')];this[_0x7ed1('0x18')]=this['available']>=0x0?this[_0x7ed1('0x18')]:0x0;var _0x48dc26={'id':this['id'],'available':this[_0x7ed1('0x18')],'loggedIn':this[_0x7ed1('0x14')],'name':this[_0x7ed1('0x8')],'paused':this[_0x7ed1('0x15')],'waiting':this[_0x7ed1('0xe')]};var _0xb9037c=md5(JSON[_0x7ed1('0x19')](_0x48dc26));if(this[_0x7ed1('0x1')]!==_0xb9037c){this['md5']=_0xb9037c;io['to'](util[_0x7ed1('0x1a')](_0x7ed1('0x1b'),_0x48dc26[_0x7ed1('0x8')]))[_0x7ed1('0x1c')](_0x7ed1('0x1d'),_0x48dc26);}};module[_0x7ed1('0x1e')]=MailQueue;