Built motion from commit (unavailable).|2.5.13
[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 _0x5fe0=['util','../../../config/environment','redis','localhost','socket.io-emitter','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','map','updateRealtime','paused','online','loggedIn','available','name','mail:queue:%s','emit','mail_queue:save','lodash','md5'];(function(_0x26b622,_0x237e9e){var _0x58a028=function(_0xde1652){while(--_0xde1652){_0x26b622['push'](_0x26b622['shift']());}};_0x58a028(++_0x237e9e);}(_0x5fe0,0xe8));var _0x05fe=function(_0x712760,_0x313c26){_0x712760=_0x712760-0x0;var _0x17e6d8=_0x5fe0[_0x712760];return _0x17e6d8;};'use strict';var _=require(_0x05fe('0x0'));var md5=require(_0x05fe('0x1'));var util=require(_0x05fe('0x2'));var Redis=require('ioredis');var config=require(_0x05fe('0x3'));config[_0x05fe('0x4')]=_['defaults'](config['redis'],{'host':_0x05fe('0x5'),'port':0x18eb});var io=require(_0x05fe('0x6'))(new Redis(config[_0x05fe('0x4')]));function MailQueue(_0xaed2bc){this['id']=_0xaed2bc['id']||0x0;this['name']=_0xaed2bc['name']||'';this[_0x05fe('0x7')]=_0xaed2bc['timeout']||0xa;this[_0x05fe('0x8')]=_0xaed2bc['strategy']||_0x05fe('0x9');this[_0x05fe('0xa')]=_0xaed2bc[_0x05fe('0xa')];this[_0x05fe('0xb')]={};this[_0x05fe('0xc')]=0x0;this['md5']='';this[_0x05fe('0xd')]();this['updateRealtime']();}MailQueue[_0x05fe('0xe')][_0x05fe('0xd')]=function(){var _0x16ebbf=this[_0x05fe('0xb')][_0x05fe('0xf')];this['mapAgentsId']=_[_0x05fe('0x10')](this['Agents'],'id');this[_0x05fe('0xb')][_0x05fe('0xf')]=_0x16ebbf;};MailQueue['prototype'][_0x05fe('0x11')]=function(){this['loggedIn']=0x0;this[_0x05fe('0x12')]=0x0;for(var _0x438b29=0x0;_0x438b29<this[_0x05fe('0xa')]['length'];_0x438b29+=0x1){if(this[_0x05fe('0xa')][_0x438b29][_0x05fe('0x13')]){this[_0x05fe('0x14')]+=0x1;}if(this[_0x05fe('0xa')][_0x438b29]['mailPause']){this[_0x05fe('0x12')]+=0x1;}}this[_0x05fe('0x15')]=this[_0x05fe('0x14')]-this['paused'];this[_0x05fe('0x15')]=this['available']>=0x0?this[_0x05fe('0x15')]:0x0;var _0x40a24f={'id':this['id'],'available':this[_0x05fe('0x15')],'loggedIn':this['loggedIn'],'name':this[_0x05fe('0x16')],'paused':this[_0x05fe('0x12')],'waiting':this[_0x05fe('0xc')]};var _0x39f861=md5(JSON['stringify'](_0x40a24f));if(this[_0x05fe('0x1')]!==_0x39f861){this['md5']=_0x39f861;io['to'](util['format'](_0x05fe('0x17'),_0x40a24f[_0x05fe('0x16')]))[_0x05fe('0x18')](_0x05fe('0x19'),_0x40a24f);}};module['exports']=MailQueue;