d6763fbb040e0c978f8952b9b6961a6af51d6f16
[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 _0xaba5=['lodash','md5','util','ioredis','../../../config/environment','redis','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRealtime','prototype','updateRouting','_rr','map','paused','length','online','loggedIn','mailPause','available','stringify','mail:queue:%s','emit','mail_queue:save'];(function(_0x5590c5,_0x1a8e1e){var _0x3519d1=function(_0x8524d2){while(--_0x8524d2){_0x5590c5['push'](_0x5590c5['shift']());}};_0x3519d1(++_0x1a8e1e);}(_0xaba5,0x105));var _0x5aba=function(_0x1b8ecd,_0x38a0ff){_0x1b8ecd=_0x1b8ecd-0x0;var _0x343c02=_0xaba5[_0x1b8ecd];return _0x343c02;};'use strict';var _=require(_0x5aba('0x0'));var md5=require(_0x5aba('0x1'));var util=require(_0x5aba('0x2'));var Redis=require(_0x5aba('0x3'));var config=require(_0x5aba('0x4'));config[_0x5aba('0x5')]=_['defaults'](config[_0x5aba('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0x5aba('0x6'))(new Redis(config[_0x5aba('0x5')]));function MailQueue(_0x198dfa){this['id']=_0x198dfa['id']||0x0;this[_0x5aba('0x7')]=_0x198dfa[_0x5aba('0x7')]||'';this[_0x5aba('0x8')]=_0x198dfa[_0x5aba('0x8')]||0xa;this[_0x5aba('0x9')]=_0x198dfa[_0x5aba('0x9')]||_0x5aba('0xa');this[_0x5aba('0xb')]=_0x198dfa['Agents'];this[_0x5aba('0xc')]={};this[_0x5aba('0xd')]=0x0;this['md5']='';this['updateRouting']();this[_0x5aba('0xe')]();}MailQueue[_0x5aba('0xf')][_0x5aba('0x10')]=function(){var _0x280733=this['mapAgentsId'][_0x5aba('0x11')];this['mapAgentsId']=_[_0x5aba('0x12')](this[_0x5aba('0xb')],'id');this[_0x5aba('0xc')][_0x5aba('0x11')]=_0x280733;};MailQueue[_0x5aba('0xf')][_0x5aba('0xe')]=function(){this['loggedIn']=0x0;this[_0x5aba('0x13')]=0x0;for(var _0x52b7ca=0x0;_0x52b7ca<this['Agents'][_0x5aba('0x14')];_0x52b7ca+=0x1){if(this[_0x5aba('0xb')][_0x52b7ca][_0x5aba('0x15')]){this[_0x5aba('0x16')]+=0x1;}if(this[_0x5aba('0xb')][_0x52b7ca][_0x5aba('0x17')]){this[_0x5aba('0x13')]+=0x1;}}this[_0x5aba('0x18')]=this[_0x5aba('0x16')]-this['paused'];this[_0x5aba('0x18')]=this['available']>=0x0?this[_0x5aba('0x18')]:0x0;var _0x31a150={'id':this['id'],'available':this[_0x5aba('0x18')],'loggedIn':this['loggedIn'],'name':this[_0x5aba('0x7')],'paused':this['paused'],'waiting':this[_0x5aba('0xd')]};var _0x189be8=md5(JSON[_0x5aba('0x19')](_0x31a150));if(this[_0x5aba('0x1')]!==_0x189be8){this[_0x5aba('0x1')]=_0x189be8;io['to'](util['format'](_0x5aba('0x1a'),_0x31a150[_0x5aba('0x7')]))[_0x5aba('0x1b')](_0x5aba('0x1c'),_0x31a150);}};module['exports']=MailQueue;