0f9ff8ba3cc4da2c79093cec023b0fec67e5f200
[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 _0x7e89=['stringify','format','mail:queue:%s','mail_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','updateRealtime','paused','loggedIn','available'];(function(_0xd0d541,_0x4cf939){var _0x488821=function(_0x5e01e3){while(--_0x5e01e3){_0xd0d541['push'](_0xd0d541['shift']());}};_0x488821(++_0x4cf939);}(_0x7e89,0x1bf));var _0x97e8=function(_0x5c4669,_0x7f9bcd){_0x5c4669=_0x5c4669-0x0;var _0xf18b6a=_0x7e89[_0x5c4669];return _0xf18b6a;};'use strict';var _=require(_0x97e8('0x0'));var md5=require(_0x97e8('0x1'));var util=require(_0x97e8('0x2'));var Redis=require(_0x97e8('0x3'));var config=require(_0x97e8('0x4'));config[_0x97e8('0x5')]=_[_0x97e8('0x6')](config[_0x97e8('0x5')],{'host':_0x97e8('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x97e8('0x5')]));function MailQueue(_0x212252){this['id']=_0x212252['id']||0x0;this[_0x97e8('0x8')]=_0x212252[_0x97e8('0x8')]||'';this[_0x97e8('0x9')]=_0x212252[_0x97e8('0x9')]||0xa;this[_0x97e8('0xa')]=_0x212252['strategy']||'beepall';this[_0x97e8('0xb')]=_0x212252[_0x97e8('0xb')];this[_0x97e8('0xc')]={};this[_0x97e8('0xd')]=0x0;this['md5']='';this[_0x97e8('0xe')]();this['updateRealtime']();}MailQueue[_0x97e8('0xf')][_0x97e8('0xe')]=function(){var _0x37dac7=this[_0x97e8('0xc')][_0x97e8('0x10')];this[_0x97e8('0xc')]=_['map'](this[_0x97e8('0xb')],'id');this[_0x97e8('0xc')][_0x97e8('0x10')]=_0x37dac7;};MailQueue[_0x97e8('0xf')][_0x97e8('0x11')]=function(){this['loggedIn']=0x0;this[_0x97e8('0x12')]=0x0;for(var _0x3d1806=0x0;_0x3d1806<this['Agents']['length'];_0x3d1806+=0x1){if(this[_0x97e8('0xb')][_0x3d1806]['online']){this[_0x97e8('0x13')]+=0x1;}if(this[_0x97e8('0xb')][_0x3d1806]['mailPause']){this[_0x97e8('0x12')]+=0x1;}}this[_0x97e8('0x14')]=this[_0x97e8('0x13')]-this['paused'];this[_0x97e8('0x14')]=this[_0x97e8('0x14')]>=0x0?this['available']:0x0;var _0x26c93a={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this[_0x97e8('0x8')],'paused':this[_0x97e8('0x12')],'waiting':this[_0x97e8('0xd')]};var _0x1ef6e7=md5(JSON[_0x97e8('0x15')](_0x26c93a));if(this[_0x97e8('0x1')]!==_0x1ef6e7){this[_0x97e8('0x1')]=_0x1ef6e7;io['to'](util[_0x97e8('0x16')](_0x97e8('0x17'),_0x26c93a[_0x97e8('0x8')]))['emit'](_0x97e8('0x18'),_0x26c93a);}};module[_0x97e8('0x19')]=MailQueue;