52efcda22fa8b9dffbf22255c4fc71270d93863b
[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 _0x6079=['redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','md5','updateRouting','prototype','_rr','map','paused','length','online','loggedIn','available','stringify','format','mail:queue:%s','emit','mail_queue:save','exports','lodash','util','ioredis','../../../config/environment'];(function(_0xbd08b4,_0x4790ed){var _0x314f1e=function(_0x161589){while(--_0x161589){_0xbd08b4['push'](_0xbd08b4['shift']());}};_0x314f1e(++_0x4790ed);}(_0x6079,0x92));var _0x9607=function(_0x24875d,_0x4fb24d){_0x24875d=_0x24875d-0x0;var _0x181471=_0x6079[_0x24875d];return _0x181471;};'use strict';var _=require(_0x9607('0x0'));var md5=require('md5');var util=require(_0x9607('0x1'));var Redis=require(_0x9607('0x2'));var config=require(_0x9607('0x3'));config[_0x9607('0x4')]=_[_0x9607('0x5')](config[_0x9607('0x4')],{'host':_0x9607('0x6'),'port':0x18eb});var io=require(_0x9607('0x7'))(new Redis(config[_0x9607('0x4')]));function MailQueue(_0x599ff6){this['id']=_0x599ff6['id']||0x0;this[_0x9607('0x8')]=_0x599ff6['name']||'';this['timeout']=_0x599ff6[_0x9607('0x9')]||0xa;this[_0x9607('0xa')]=_0x599ff6[_0x9607('0xa')]||'beepall';this[_0x9607('0xb')]=_0x599ff6[_0x9607('0xb')];this[_0x9607('0xc')]={};this[_0x9607('0xd')]=0x0;this[_0x9607('0xe')]='';this[_0x9607('0xf')]();this['updateRealtime']();}MailQueue[_0x9607('0x10')][_0x9607('0xf')]=function(){var _0xd91193=this[_0x9607('0xc')][_0x9607('0x11')];this['mapAgentsId']=_[_0x9607('0x12')](this[_0x9607('0xb')],'id');this['mapAgentsId']['_rr']=_0xd91193;};MailQueue['prototype']['updateRealtime']=function(){this['loggedIn']=0x0;this[_0x9607('0x13')]=0x0;for(var _0x501059=0x0;_0x501059<this[_0x9607('0xb')][_0x9607('0x14')];_0x501059+=0x1){if(this[_0x9607('0xb')][_0x501059][_0x9607('0x15')]){this[_0x9607('0x16')]+=0x1;}if(this['Agents'][_0x501059]['mailPause']){this[_0x9607('0x13')]+=0x1;}}this[_0x9607('0x17')]=this[_0x9607('0x16')]-this[_0x9607('0x13')];this[_0x9607('0x17')]=this[_0x9607('0x17')]>=0x0?this['available']:0x0;var _0x36f392={'id':this['id'],'available':this[_0x9607('0x17')],'loggedIn':this[_0x9607('0x16')],'name':this['name'],'paused':this['paused'],'waiting':this[_0x9607('0xd')]};var _0x4fb907=md5(JSON[_0x9607('0x18')](_0x36f392));if(this['md5']!==_0x4fb907){this['md5']=_0x4fb907;io['to'](util[_0x9607('0x19')](_0x9607('0x1a'),_0x36f392[_0x9607('0x8')]))[_0x9607('0x1b')](_0x9607('0x1c'),_0x36f392);}};module[_0x9607('0x1d')]=MailQueue;