40d0e9f159bfe31d8ae0f959cec2d85d0558fd8a
[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 _0x705f=['strategy','beepall','Agents','waiting','updateRouting','updateRealtime','prototype','mapAgentsId','_rr','loggedIn','paused','length','online','mailPause','available','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','util','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout'];(function(_0xf84870,_0x4dc38f){var _0x4541a4=function(_0x3ff5d5){while(--_0x3ff5d5){_0xf84870['push'](_0xf84870['shift']());}};_0x4541a4(++_0x4dc38f);}(_0x705f,0xa4));var _0xf705=function(_0x46fd05,_0x2a121d){_0x46fd05=_0x46fd05-0x0;var _0xdcbee=_0x705f[_0x46fd05];return _0xdcbee;};'use strict';var _=require(_0xf705('0x0'));var md5=require(_0xf705('0x1'));var util=require(_0xf705('0x2'));var Redis=require('ioredis');var config=require(_0xf705('0x3'));config[_0xf705('0x4')]=_[_0xf705('0x5')](config[_0xf705('0x4')],{'host':_0xf705('0x6'),'port':0x18eb});var io=require(_0xf705('0x7'))(new Redis(config[_0xf705('0x4')]));function MailQueue(_0x380073){this['id']=_0x380073['id']||0x0;this[_0xf705('0x8')]=_0x380073['name']||'';this[_0xf705('0x9')]=_0x380073[_0xf705('0x9')]||0xa;this['strategy']=_0x380073[_0xf705('0xa')]||_0xf705('0xb');this[_0xf705('0xc')]=_0x380073['Agents'];this['mapAgentsId']={};this[_0xf705('0xd')]=0x0;this['md5']='';this[_0xf705('0xe')]();this[_0xf705('0xf')]();}MailQueue[_0xf705('0x10')][_0xf705('0xe')]=function(){var _0x225cb8=this[_0xf705('0x11')][_0xf705('0x12')];this[_0xf705('0x11')]=_['map'](this[_0xf705('0xc')],'id');this['mapAgentsId'][_0xf705('0x12')]=_0x225cb8;};MailQueue[_0xf705('0x10')][_0xf705('0xf')]=function(){this[_0xf705('0x13')]=0x0;this[_0xf705('0x14')]=0x0;for(var _0x46397a=0x0;_0x46397a<this[_0xf705('0xc')][_0xf705('0x15')];_0x46397a+=0x1){if(this[_0xf705('0xc')][_0x46397a][_0xf705('0x16')]){this[_0xf705('0x13')]+=0x1;}if(this[_0xf705('0xc')][_0x46397a][_0xf705('0x17')]){this['paused']+=0x1;}}this[_0xf705('0x18')]=this['loggedIn']-this['paused'];this[_0xf705('0x18')]=this[_0xf705('0x18')]>=0x0?this[_0xf705('0x18')]:0x0;var _0x1a0ab5={'id':this['id'],'available':this[_0xf705('0x18')],'loggedIn':this[_0xf705('0x13')],'name':this[_0xf705('0x8')],'paused':this[_0xf705('0x14')],'waiting':this[_0xf705('0xd')]};var _0xc8dd23=md5(JSON['stringify'](_0x1a0ab5));if(this[_0xf705('0x1')]!==_0xc8dd23){this[_0xf705('0x1')]=_0xc8dd23;io['to'](util['format'](_0xf705('0x19'),_0x1a0ab5[_0xf705('0x8')]))[_0xf705('0x1a')](_0xf705('0x1b'),_0x1a0ab5);}};module[_0xf705('0x1c')]=MailQueue;