231e289cc3a049350c684618b71ee5b3994e4d78
[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 _0x078a=['exports','lodash','md5','util','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','updateRouting','updateRealtime','mapAgentsId','_rr','prototype','loggedIn','paused','length','online','mailPause','available','stringify','format','emit','mail_queue:save'];(function(_0x5c1343,_0x5ad283){var _0x1025f3=function(_0x1b8025){while(--_0x1b8025){_0x5c1343['push'](_0x5c1343['shift']());}};_0x1025f3(++_0x5ad283);}(_0x078a,0x12d));var _0xa078=function(_0x164191,_0x10a33b){_0x164191=_0x164191-0x0;var _0x5a51ee=_0x078a[_0x164191];return _0x5a51ee;};'use strict';var _=require(_0xa078('0x0'));var md5=require(_0xa078('0x1'));var util=require(_0xa078('0x2'));var Redis=require(_0xa078('0x3'));var config=require(_0xa078('0x4'));config[_0xa078('0x5')]=_['defaults'](config[_0xa078('0x5')],{'host':_0xa078('0x6'),'port':0x18eb});var io=require(_0xa078('0x7'))(new Redis(config['redis']));function MailQueue(_0xe1f165){this['id']=_0xe1f165['id']||0x0;this['name']=_0xe1f165[_0xa078('0x8')]||'';this[_0xa078('0x9')]=_0xe1f165[_0xa078('0x9')]||0xa;this[_0xa078('0xa')]=_0xe1f165[_0xa078('0xa')]||_0xa078('0xb');this[_0xa078('0xc')]=_0xe1f165[_0xa078('0xc')];this['mapAgentsId']={};this[_0xa078('0xd')]=0x0;this[_0xa078('0x1')]='';this[_0xa078('0xe')]();this[_0xa078('0xf')]();}MailQueue['prototype'][_0xa078('0xe')]=function(){var _0x210400=this[_0xa078('0x10')][_0xa078('0x11')];this[_0xa078('0x10')]=_['map'](this[_0xa078('0xc')],'id');this[_0xa078('0x10')][_0xa078('0x11')]=_0x210400;};MailQueue[_0xa078('0x12')][_0xa078('0xf')]=function(){this[_0xa078('0x13')]=0x0;this[_0xa078('0x14')]=0x0;for(var _0x214106=0x0;_0x214106<this[_0xa078('0xc')][_0xa078('0x15')];_0x214106+=0x1){if(this[_0xa078('0xc')][_0x214106][_0xa078('0x16')]){this['loggedIn']+=0x1;}if(this[_0xa078('0xc')][_0x214106][_0xa078('0x17')]){this[_0xa078('0x14')]+=0x1;}}this['available']=this[_0xa078('0x13')]-this[_0xa078('0x14')];this['available']=this[_0xa078('0x18')]>=0x0?this[_0xa078('0x18')]:0x0;var _0x389474={'id':this['id'],'available':this['available'],'loggedIn':this[_0xa078('0x13')],'name':this[_0xa078('0x8')],'paused':this[_0xa078('0x14')],'waiting':this[_0xa078('0xd')]};var _0x37780c=md5(JSON[_0xa078('0x19')](_0x389474));if(this['md5']!==_0x37780c){this['md5']=_0x37780c;io['to'](util[_0xa078('0x1a')]('mail:queue:%s',_0x389474[_0xa078('0x8')]))[_0xa078('0x1b')](_0xa078('0x1c'),_0x389474);}};module[_0xa078('0x1d')]=MailQueue;