Built motion from commit 9e1399f3.|2.5.37
[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 _0xaf8b=['strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','_rr','paused','length','online','loggedIn','mailPause','available','waiting','stringify','format','mail:queue:%s','lodash','md5','util','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout'];(function(_0x39cf70,_0x3ec55b){var _0x580424=function(_0x580a4e){while(--_0x580a4e){_0x39cf70['push'](_0x39cf70['shift']());}};_0x580424(++_0x3ec55b);}(_0xaf8b,0x162));var _0xbaf8=function(_0x24de1d,_0x5c25c7){_0x24de1d=_0x24de1d-0x0;var _0x1f6f90=_0xaf8b[_0x24de1d];return _0x1f6f90;};'use strict';var _=require(_0xbaf8('0x0'));var md5=require(_0xbaf8('0x1'));var util=require(_0xbaf8('0x2'));var Redis=require(_0xbaf8('0x3'));var config=require(_0xbaf8('0x4'));config[_0xbaf8('0x5')]=_['defaults'](config[_0xbaf8('0x5')],{'host':_0xbaf8('0x6'),'port':0x18eb});var io=require(_0xbaf8('0x7'))(new Redis(config[_0xbaf8('0x5')]));function MailQueue(_0x550f88){this['id']=_0x550f88['id']||0x0;this[_0xbaf8('0x8')]=_0x550f88[_0xbaf8('0x8')]||'';this[_0xbaf8('0x9')]=_0x550f88[_0xbaf8('0x9')]||0xa;this[_0xbaf8('0xa')]=_0x550f88[_0xbaf8('0xa')]||_0xbaf8('0xb');this['Agents']=_0x550f88[_0xbaf8('0xc')];this[_0xbaf8('0xd')]={};this['waiting']=0x0;this[_0xbaf8('0x1')]='';this[_0xbaf8('0xe')]();this[_0xbaf8('0xf')]();}MailQueue[_0xbaf8('0x10')]['updateRouting']=function(){var _0x43e903=this[_0xbaf8('0xd')][_0xbaf8('0x11')];this[_0xbaf8('0xd')]=_['map'](this[_0xbaf8('0xc')],'id');this['mapAgentsId']['_rr']=_0x43e903;};MailQueue['prototype'][_0xbaf8('0xf')]=function(){this['loggedIn']=0x0;this[_0xbaf8('0x12')]=0x0;for(var _0x40b80b=0x0;_0x40b80b<this['Agents'][_0xbaf8('0x13')];_0x40b80b+=0x1){if(this['Agents'][_0x40b80b][_0xbaf8('0x14')]){this[_0xbaf8('0x15')]+=0x1;}if(this[_0xbaf8('0xc')][_0x40b80b][_0xbaf8('0x16')]){this['paused']+=0x1;}}this[_0xbaf8('0x17')]=this[_0xbaf8('0x15')]-this[_0xbaf8('0x12')];this[_0xbaf8('0x17')]=this[_0xbaf8('0x17')]>=0x0?this[_0xbaf8('0x17')]:0x0;var _0x2fd5e9={'id':this['id'],'available':this[_0xbaf8('0x17')],'loggedIn':this[_0xbaf8('0x15')],'name':this[_0xbaf8('0x8')],'paused':this[_0xbaf8('0x12')],'waiting':this[_0xbaf8('0x18')]};var _0x5f305c=md5(JSON[_0xbaf8('0x19')](_0x2fd5e9));if(this[_0xbaf8('0x1')]!==_0x5f305c){this['md5']=_0x5f305c;io['to'](util[_0xbaf8('0x1a')](_0xbaf8('0x1b'),_0x2fd5e9['name']))['emit']('mail_queue:save',_0x2fd5e9);}};module['exports']=MailQueue;