Built motion from commit (unavailable).|2.5.15
[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 _0x13ef=['strategy','Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','map','updateRealtime','loggedIn','paused','length','online','available','stringify','format','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','util','ioredis','redis','socket.io-emitter','name','timeout'];(function(_0xd1d19a,_0x1933f0){var _0x52a79d=function(_0x5199e2){while(--_0x5199e2){_0xd1d19a['push'](_0xd1d19a['shift']());}};_0x52a79d(++_0x1933f0);}(_0x13ef,0x19c));var _0xf13e=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0x13ef[_0x122ef9];return _0x42fba0;};'use strict';var _=require(_0xf13e('0x0'));var md5=require(_0xf13e('0x1'));var util=require(_0xf13e('0x2'));var Redis=require(_0xf13e('0x3'));var config=require('../../../config/environment');config['redis']=_['defaults'](config[_0xf13e('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0xf13e('0x5'))(new Redis(config[_0xf13e('0x4')]));function MailQueue(_0x44484c){this['id']=_0x44484c['id']||0x0;this['name']=_0x44484c[_0xf13e('0x6')]||'';this[_0xf13e('0x7')]=_0x44484c[_0xf13e('0x7')]||0xa;this['strategy']=_0x44484c[_0xf13e('0x8')]||'beepall';this[_0xf13e('0x9')]=_0x44484c['Agents'];this[_0xf13e('0xa')]={};this[_0xf13e('0xb')]=0x0;this[_0xf13e('0x1')]='';this[_0xf13e('0xc')]();this['updateRealtime']();}MailQueue[_0xf13e('0xd')][_0xf13e('0xc')]=function(){var _0x33a5f9=this[_0xf13e('0xa')][_0xf13e('0xe')];this[_0xf13e('0xa')]=_[_0xf13e('0xf')](this[_0xf13e('0x9')],'id');this[_0xf13e('0xa')][_0xf13e('0xe')]=_0x33a5f9;};MailQueue[_0xf13e('0xd')][_0xf13e('0x10')]=function(){this[_0xf13e('0x11')]=0x0;this[_0xf13e('0x12')]=0x0;for(var _0x406734=0x0;_0x406734<this[_0xf13e('0x9')][_0xf13e('0x13')];_0x406734+=0x1){if(this[_0xf13e('0x9')][_0x406734][_0xf13e('0x14')]){this[_0xf13e('0x11')]+=0x1;}if(this['Agents'][_0x406734]['mailPause']){this['paused']+=0x1;}}this[_0xf13e('0x15')]=this[_0xf13e('0x11')]-this[_0xf13e('0x12')];this[_0xf13e('0x15')]=this['available']>=0x0?this[_0xf13e('0x15')]:0x0;var _0x3f53a4={'id':this['id'],'available':this[_0xf13e('0x15')],'loggedIn':this[_0xf13e('0x11')],'name':this[_0xf13e('0x6')],'paused':this[_0xf13e('0x12')],'waiting':this['waiting']};var _0x462967=md5(JSON[_0xf13e('0x16')](_0x3f53a4));if(this[_0xf13e('0x1')]!==_0x462967){this['md5']=_0x462967;io['to'](util[_0xf13e('0x17')](_0xf13e('0x18'),_0x3f53a4[_0xf13e('0x6')]))[_0xf13e('0x19')](_0xf13e('0x1a'),_0x3f53a4);}};module[_0xf13e('0x1b')]=MailQueue;