e5cf2874afeb7856031e1706e47e93f923533634
[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 _0x59fd=['redis','defaults','localhost','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','_rr','prototype','loggedIn','paused','length','available','stringify','format','emit','mail_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment'];(function(_0x178a60,_0x3b374b){var _0x14731e=function(_0x35aa2c){while(--_0x35aa2c){_0x178a60['push'](_0x178a60['shift']());}};_0x14731e(++_0x3b374b);}(_0x59fd,0x1f3));var _0xd59f=function(_0x4b66f1,_0x3290d5){_0x4b66f1=_0x4b66f1-0x0;var _0x4487e0=_0x59fd[_0x4b66f1];return _0x4487e0;};'use strict';var _=require(_0xd59f('0x0'));var md5=require(_0xd59f('0x1'));var util=require(_0xd59f('0x2'));var Redis=require(_0xd59f('0x3'));var config=require(_0xd59f('0x4'));config[_0xd59f('0x5')]=_[_0xd59f('0x6')](config[_0xd59f('0x5')],{'host':_0xd59f('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xd59f('0x5')]));function MailQueue(_0x479cc9){this['id']=_0x479cc9['id']||0x0;this[_0xd59f('0x8')]=_0x479cc9['name']||'';this['timeout']=_0x479cc9[_0xd59f('0x9')]||0xa;this[_0xd59f('0xa')]=_0x479cc9[_0xd59f('0xa')]||_0xd59f('0xb');this['Agents']=_0x479cc9[_0xd59f('0xc')];this[_0xd59f('0xd')]={};this[_0xd59f('0xe')]=0x0;this[_0xd59f('0x1')]='';this[_0xd59f('0xf')]();this[_0xd59f('0x10')]();}MailQueue['prototype'][_0xd59f('0xf')]=function(){var _0x6ca6d7=this[_0xd59f('0xd')][_0xd59f('0x11')];this[_0xd59f('0xd')]=_['map'](this[_0xd59f('0xc')],'id');this[_0xd59f('0xd')]['_rr']=_0x6ca6d7;};MailQueue[_0xd59f('0x12')][_0xd59f('0x10')]=function(){this[_0xd59f('0x13')]=0x0;this[_0xd59f('0x14')]=0x0;for(var _0x48cbdc=0x0;_0x48cbdc<this['Agents'][_0xd59f('0x15')];_0x48cbdc+=0x1){if(this[_0xd59f('0xc')][_0x48cbdc]['online']){this[_0xd59f('0x13')]+=0x1;}if(this['Agents'][_0x48cbdc]['mailPause']){this['paused']+=0x1;}}this['available']=this['loggedIn']-this['paused'];this[_0xd59f('0x16')]=this[_0xd59f('0x16')]>=0x0?this[_0xd59f('0x16')]:0x0;var _0x2c2868={'id':this['id'],'available':this['available'],'loggedIn':this[_0xd59f('0x13')],'name':this[_0xd59f('0x8')],'paused':this[_0xd59f('0x14')],'waiting':this['waiting']};var _0x4b19f7=md5(JSON[_0xd59f('0x17')](_0x2c2868));if(this['md5']!==_0x4b19f7){this[_0xd59f('0x1')]=_0x4b19f7;io['to'](util[_0xd59f('0x18')]('mail:queue:%s',_0x2c2868[_0xd59f('0x8')]))[_0xd59f('0x19')](_0xd59f('0x1a'),_0x2c2868);}};module[_0xd59f('0x1b')]=MailQueue;