Built motion from commit 14588770.|2.5.38
[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 _0x7e2d=['available','stringify','mail:queue:%s','emit','exports','lodash','util','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','md5','prototype','updateRouting','_rr','map','updateRealtime','loggedIn','paused','length','online'];(function(_0x3f994e,_0x6f0bb8){var _0x40dbcf=function(_0x1a7b09){while(--_0x1a7b09){_0x3f994e['push'](_0x3f994e['shift']());}};_0x40dbcf(++_0x6f0bb8);}(_0x7e2d,0xd0));var _0xd7e2=function(_0x494d1f,_0x3f72ff){_0x494d1f=_0x494d1f-0x0;var _0x457b6e=_0x7e2d[_0x494d1f];return _0x457b6e;};'use strict';var _=require(_0xd7e2('0x0'));var md5=require('md5');var util=require(_0xd7e2('0x1'));var Redis=require(_0xd7e2('0x2'));var config=require('../../../config/environment');config[_0xd7e2('0x3')]=_[_0xd7e2('0x4')](config[_0xd7e2('0x3')],{'host':_0xd7e2('0x5'),'port':0x18eb});var io=require(_0xd7e2('0x6'))(new Redis(config[_0xd7e2('0x3')]));function MailQueue(_0xe1c5af){this['id']=_0xe1c5af['id']||0x0;this[_0xd7e2('0x7')]=_0xe1c5af[_0xd7e2('0x7')]||'';this['timeout']=_0xe1c5af[_0xd7e2('0x8')]||0xa;this[_0xd7e2('0x9')]=_0xe1c5af[_0xd7e2('0x9')]||_0xd7e2('0xa');this['Agents']=_0xe1c5af[_0xd7e2('0xb')];this[_0xd7e2('0xc')]={};this[_0xd7e2('0xd')]=0x0;this[_0xd7e2('0xe')]='';this['updateRouting']();this['updateRealtime']();}MailQueue[_0xd7e2('0xf')][_0xd7e2('0x10')]=function(){var _0x4a3aa2=this[_0xd7e2('0xc')][_0xd7e2('0x11')];this[_0xd7e2('0xc')]=_[_0xd7e2('0x12')](this[_0xd7e2('0xb')],'id');this[_0xd7e2('0xc')][_0xd7e2('0x11')]=_0x4a3aa2;};MailQueue[_0xd7e2('0xf')][_0xd7e2('0x13')]=function(){this[_0xd7e2('0x14')]=0x0;this[_0xd7e2('0x15')]=0x0;for(var _0x5a7819=0x0;_0x5a7819<this[_0xd7e2('0xb')][_0xd7e2('0x16')];_0x5a7819+=0x1){if(this[_0xd7e2('0xb')][_0x5a7819][_0xd7e2('0x17')]){this[_0xd7e2('0x14')]+=0x1;}if(this['Agents'][_0x5a7819]['mailPause']){this['paused']+=0x1;}}this['available']=this[_0xd7e2('0x14')]-this[_0xd7e2('0x15')];this[_0xd7e2('0x18')]=this[_0xd7e2('0x18')]>=0x0?this[_0xd7e2('0x18')]:0x0;var _0x197dac={'id':this['id'],'available':this[_0xd7e2('0x18')],'loggedIn':this[_0xd7e2('0x14')],'name':this[_0xd7e2('0x7')],'paused':this['paused'],'waiting':this['waiting']};var _0x180d7b=md5(JSON[_0xd7e2('0x19')](_0x197dac));if(this['md5']!==_0x180d7b){this[_0xd7e2('0xe')]=_0x180d7b;io['to'](util['format'](_0xd7e2('0x1a'),_0x197dac[_0xd7e2('0x7')]))[_0xd7e2('0x1b')]('mail_queue:save',_0x197dac);}};module[_0xd7e2('0x1c')]=MailQueue;