Built motion from commit 06a208af.|2.6.26
[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 _0xe2d2=['online','mailPause','available','stringify','format','mail:queue:%s','emit','mail_queue:save','lodash','md5','util','ioredis','defaults','redis','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length'];(function(_0x135c17,_0x1188b2){var _0x2546b0=function(_0x23a1f9){while(--_0x23a1f9){_0x135c17['push'](_0x135c17['shift']());}};_0x2546b0(++_0x1188b2);}(_0xe2d2,0x1e8));var _0x2e2d=function(_0xeee372,_0x408f0a){_0xeee372=_0xeee372-0x0;var _0x1e925e=_0xe2d2[_0xeee372];return _0x1e925e;};'use strict';var _=require(_0x2e2d('0x0'));var md5=require(_0x2e2d('0x1'));var util=require(_0x2e2d('0x2'));var Redis=require(_0x2e2d('0x3'));var config=require('../../../config/environment');config['redis']=_[_0x2e2d('0x4')](config[_0x2e2d('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0x2e2d('0x6'))(new Redis(config[_0x2e2d('0x5')]));function MailQueue(_0x2c2834){this['id']=_0x2c2834['id']||0x0;this[_0x2e2d('0x7')]=_0x2c2834[_0x2e2d('0x7')]||'';this['timeout']=_0x2c2834[_0x2e2d('0x8')]||0xa;this[_0x2e2d('0x9')]=_0x2c2834[_0x2e2d('0x9')]||_0x2e2d('0xa');this[_0x2e2d('0xb')]=_0x2c2834['Agents'];this[_0x2e2d('0xc')]={};this[_0x2e2d('0xd')]=0x0;this[_0x2e2d('0x1')]='';this[_0x2e2d('0xe')]();this[_0x2e2d('0xf')]();}MailQueue[_0x2e2d('0x10')][_0x2e2d('0xe')]=function(){var _0x463fcf=this[_0x2e2d('0xc')][_0x2e2d('0x11')];this[_0x2e2d('0xc')]=_[_0x2e2d('0x12')](this[_0x2e2d('0xb')],'id');this[_0x2e2d('0xc')][_0x2e2d('0x11')]=_0x463fcf;};MailQueue[_0x2e2d('0x10')][_0x2e2d('0xf')]=function(){this[_0x2e2d('0x13')]=0x0;this[_0x2e2d('0x14')]=0x0;for(var _0x3d6646=0x0;_0x3d6646<this[_0x2e2d('0xb')][_0x2e2d('0x15')];_0x3d6646+=0x1){if(this[_0x2e2d('0xb')][_0x3d6646][_0x2e2d('0x16')]){this[_0x2e2d('0x13')]+=0x1;}if(this[_0x2e2d('0xb')][_0x3d6646][_0x2e2d('0x17')]){this[_0x2e2d('0x14')]+=0x1;}}this[_0x2e2d('0x18')]=this['loggedIn']-this[_0x2e2d('0x14')];this[_0x2e2d('0x18')]=this[_0x2e2d('0x18')]>=0x0?this['available']:0x0;var _0x22dc04={'id':this['id'],'available':this['available'],'loggedIn':this[_0x2e2d('0x13')],'name':this[_0x2e2d('0x7')],'paused':this['paused'],'waiting':this[_0x2e2d('0xd')]};var _0xbad0a9=md5(JSON[_0x2e2d('0x19')](_0x22dc04));if(this[_0x2e2d('0x1')]!==_0xbad0a9){this[_0x2e2d('0x1')]=_0xbad0a9;io['to'](util[_0x2e2d('0x1a')](_0x2e2d('0x1b'),_0x22dc04['name']))[_0x2e2d('0x1c')](_0x2e2d('0x1d'),_0x22dc04);}};module['exports']=MailQueue;