Built motion from commit c738b9ac.|2.6.25
[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 _0xc8d6=['length','online','mailPause','available','stringify','mail:queue:%s','emit','mail_queue:save','md5','util','ioredis','defaults','redis','localhost','socket.io-emitter','name','timeout','strategy','Agents','waiting','updateRouting','updateRealtime','prototype','_rr','mapAgentsId','map','loggedIn','paused'];(function(_0x27604f,_0x5ae336){var _0x40d189=function(_0xebacde){while(--_0xebacde){_0x27604f['push'](_0x27604f['shift']());}};_0x40d189(++_0x5ae336);}(_0xc8d6,0x120));var _0x6c8d=function(_0x2207fc,_0x424044){_0x2207fc=_0x2207fc-0x0;var _0x3d7025=_0xc8d6[_0x2207fc];return _0x3d7025;};'use strict';var _=require('lodash');var md5=require(_0x6c8d('0x0'));var util=require(_0x6c8d('0x1'));var Redis=require(_0x6c8d('0x2'));var config=require('../../../config/environment');config['redis']=_[_0x6c8d('0x3')](config[_0x6c8d('0x4')],{'host':_0x6c8d('0x5'),'port':0x18eb});var io=require(_0x6c8d('0x6'))(new Redis(config['redis']));function MailQueue(_0x210dbe){this['id']=_0x210dbe['id']||0x0;this['name']=_0x210dbe[_0x6c8d('0x7')]||'';this[_0x6c8d('0x8')]=_0x210dbe['timeout']||0xa;this[_0x6c8d('0x9')]=_0x210dbe[_0x6c8d('0x9')]||'beepall';this['Agents']=_0x210dbe[_0x6c8d('0xa')];this['mapAgentsId']={};this[_0x6c8d('0xb')]=0x0;this[_0x6c8d('0x0')]='';this[_0x6c8d('0xc')]();this[_0x6c8d('0xd')]();}MailQueue[_0x6c8d('0xe')][_0x6c8d('0xc')]=function(){var _0x1ad5bb=this['mapAgentsId'][_0x6c8d('0xf')];this[_0x6c8d('0x10')]=_[_0x6c8d('0x11')](this[_0x6c8d('0xa')],'id');this[_0x6c8d('0x10')][_0x6c8d('0xf')]=_0x1ad5bb;};MailQueue[_0x6c8d('0xe')][_0x6c8d('0xd')]=function(){this[_0x6c8d('0x12')]=0x0;this[_0x6c8d('0x13')]=0x0;for(var _0x59cc3a=0x0;_0x59cc3a<this[_0x6c8d('0xa')][_0x6c8d('0x14')];_0x59cc3a+=0x1){if(this['Agents'][_0x59cc3a][_0x6c8d('0x15')]){this[_0x6c8d('0x12')]+=0x1;}if(this['Agents'][_0x59cc3a][_0x6c8d('0x16')]){this['paused']+=0x1;}}this[_0x6c8d('0x17')]=this[_0x6c8d('0x12')]-this[_0x6c8d('0x13')];this['available']=this[_0x6c8d('0x17')]>=0x0?this[_0x6c8d('0x17')]:0x0;var _0x569160={'id':this['id'],'available':this[_0x6c8d('0x17')],'loggedIn':this['loggedIn'],'name':this[_0x6c8d('0x7')],'paused':this['paused'],'waiting':this['waiting']};var _0x3bd9b2=md5(JSON[_0x6c8d('0x18')](_0x569160));if(this[_0x6c8d('0x0')]!==_0x3bd9b2){this['md5']=_0x3bd9b2;io['to'](util['format'](_0x6c8d('0x19'),_0x569160[_0x6c8d('0x7')]))[_0x6c8d('0x1a')](_0x6c8d('0x1b'),_0x569160);}};module['exports']=MailQueue;