Built motion from commit (unavailable).|2.5.1
[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 _0x3cae=['length','online','loggedIn','available','stringify','format','mail:queue:%s','emit','mail_queue:save','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRealtime','updateRouting','_rr','prototype','paused'];(function(_0x565c49,_0x54acd0){var _0x20ca34=function(_0x42f7e1){while(--_0x42f7e1){_0x565c49['push'](_0x565c49['shift']());}};_0x20ca34(++_0x54acd0);}(_0x3cae,0x117));var _0xe3ca=function(_0x19e35c,_0x29cd1e){_0x19e35c=_0x19e35c-0x0;var _0x3e1fe8=_0x3cae[_0x19e35c];return _0x3e1fe8;};'use strict';var _=require(_0xe3ca('0x0'));var md5=require(_0xe3ca('0x1'));var util=require(_0xe3ca('0x2'));var Redis=require(_0xe3ca('0x3'));var config=require(_0xe3ca('0x4'));config[_0xe3ca('0x5')]=_[_0xe3ca('0x6')](config['redis'],{'host':_0xe3ca('0x7'),'port':0x18eb});var io=require(_0xe3ca('0x8'))(new Redis(config['redis']));function MailQueue(_0x33c472){this['id']=_0x33c472['id']||0x0;this['name']=_0x33c472[_0xe3ca('0x9')]||'';this[_0xe3ca('0xa')]=_0x33c472[_0xe3ca('0xa')]||0xa;this['strategy']=_0x33c472[_0xe3ca('0xb')]||_0xe3ca('0xc');this[_0xe3ca('0xd')]=_0x33c472[_0xe3ca('0xd')];this[_0xe3ca('0xe')]={};this[_0xe3ca('0xf')]=0x0;this[_0xe3ca('0x1')]='';this['updateRouting']();this[_0xe3ca('0x10')]();}MailQueue['prototype'][_0xe3ca('0x11')]=function(){var _0x3ded4b=this[_0xe3ca('0xe')][_0xe3ca('0x12')];this[_0xe3ca('0xe')]=_['map'](this['Agents'],'id');this[_0xe3ca('0xe')]['_rr']=_0x3ded4b;};MailQueue[_0xe3ca('0x13')][_0xe3ca('0x10')]=function(){this['loggedIn']=0x0;this[_0xe3ca('0x14')]=0x0;for(var _0x3a9455=0x0;_0x3a9455<this[_0xe3ca('0xd')][_0xe3ca('0x15')];_0x3a9455+=0x1){if(this[_0xe3ca('0xd')][_0x3a9455][_0xe3ca('0x16')]){this[_0xe3ca('0x17')]+=0x1;}if(this[_0xe3ca('0xd')][_0x3a9455]['mailPause']){this['paused']+=0x1;}}this[_0xe3ca('0x18')]=this[_0xe3ca('0x17')]-this[_0xe3ca('0x14')];this[_0xe3ca('0x18')]=this[_0xe3ca('0x18')]>=0x0?this[_0xe3ca('0x18')]:0x0;var _0x5bb8d8={'id':this['id'],'available':this[_0xe3ca('0x18')],'loggedIn':this[_0xe3ca('0x17')],'name':this[_0xe3ca('0x9')],'paused':this['paused'],'waiting':this['waiting']};var _0x47f3fb=md5(JSON[_0xe3ca('0x19')](_0x5bb8d8));if(this['md5']!==_0x47f3fb){this['md5']=_0x47f3fb;io['to'](util[_0xe3ca('0x1a')](_0xe3ca('0x1b'),_0x5bb8d8[_0xe3ca('0x9')]))[_0xe3ca('0x1c')](_0xe3ca('0x1d'),_0x5bb8d8);}};module['exports']=MailQueue;