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