Built motion from commit (unavailable).|2.5.4
[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 _0xf3d4=['available','waiting','format','mail:queue:%s','mail_queue:save','lodash','../../../config/environment','defaults','redis','localhost','socket.io-emitter','name','strategy','beepall','Agents','mapAgentsId','md5','updateRealtime','prototype','updateRouting','map','_rr','loggedIn','length','online','mailPause','paused'];(function(_0xdefbc3,_0x1ea49a){var _0x367798=function(_0x594678){while(--_0x594678){_0xdefbc3['push'](_0xdefbc3['shift']());}};_0x367798(++_0x1ea49a);}(_0xf3d4,0x71));var _0x4f3d=function(_0x9b424b,_0x3ea127){_0x9b424b=_0x9b424b-0x0;var _0x1dcfee=_0xf3d4[_0x9b424b];return _0x1dcfee;};'use strict';var _=require(_0x4f3d('0x0'));var md5=require('md5');var util=require('util');var Redis=require('ioredis');var config=require(_0x4f3d('0x1'));config['redis']=_[_0x4f3d('0x2')](config[_0x4f3d('0x3')],{'host':_0x4f3d('0x4'),'port':0x18eb});var io=require(_0x4f3d('0x5'))(new Redis(config[_0x4f3d('0x3')]));function MailQueue(_0x59eff2){this['id']=_0x59eff2['id']||0x0;this[_0x4f3d('0x6')]=_0x59eff2['name']||'';this['timeout']=_0x59eff2['timeout']||0xa;this[_0x4f3d('0x7')]=_0x59eff2[_0x4f3d('0x7')]||_0x4f3d('0x8');this[_0x4f3d('0x9')]=_0x59eff2[_0x4f3d('0x9')];this[_0x4f3d('0xa')]={};this['waiting']=0x0;this[_0x4f3d('0xb')]='';this['updateRouting']();this[_0x4f3d('0xc')]();}MailQueue[_0x4f3d('0xd')][_0x4f3d('0xe')]=function(){var _0x9eed9=this[_0x4f3d('0xa')]['_rr'];this['mapAgentsId']=_[_0x4f3d('0xf')](this[_0x4f3d('0x9')],'id');this['mapAgentsId'][_0x4f3d('0x10')]=_0x9eed9;};MailQueue[_0x4f3d('0xd')][_0x4f3d('0xc')]=function(){this[_0x4f3d('0x11')]=0x0;this['paused']=0x0;for(var _0x484260=0x0;_0x484260<this[_0x4f3d('0x9')][_0x4f3d('0x12')];_0x484260+=0x1){if(this[_0x4f3d('0x9')][_0x484260][_0x4f3d('0x13')]){this[_0x4f3d('0x11')]+=0x1;}if(this[_0x4f3d('0x9')][_0x484260][_0x4f3d('0x14')]){this['paused']+=0x1;}}this['available']=this[_0x4f3d('0x11')]-this[_0x4f3d('0x15')];this[_0x4f3d('0x16')]=this[_0x4f3d('0x16')]>=0x0?this[_0x4f3d('0x16')]:0x0;var _0x26e4ef={'id':this['id'],'available':this['available'],'loggedIn':this[_0x4f3d('0x11')],'name':this[_0x4f3d('0x6')],'paused':this[_0x4f3d('0x15')],'waiting':this[_0x4f3d('0x17')]};var _0x41d8d1=md5(JSON['stringify'](_0x26e4ef));if(this[_0x4f3d('0xb')]!==_0x41d8d1){this[_0x4f3d('0xb')]=_0x41d8d1;io['to'](util[_0x4f3d('0x18')](_0x4f3d('0x19'),_0x26e4ef[_0x4f3d('0x6')]))['emit'](_0x4f3d('0x1a'),_0x26e4ef);}};module['exports']=MailQueue;