1082e11b1babd507ed316bb769ffcf24fc2ea6a9
[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 _0x8fb1=['localhost','socket.io-emitter','timeout','strategy','beepall','Agents','waiting','updateRouting','updateRealtime','prototype','_rr','mapAgentsId','loggedIn','paused','length','online','mailPause','available','name','stringify','mail:queue:%s','lodash','md5','ioredis','../../../config/environment','defaults','redis'];(function(_0x3dbaf5,_0x442483){var _0x560000=function(_0x11f46c){while(--_0x11f46c){_0x3dbaf5['push'](_0x3dbaf5['shift']());}};_0x560000(++_0x442483);}(_0x8fb1,0x13e));var _0x18fb=function(_0x21a02a,_0x11d2d1){_0x21a02a=_0x21a02a-0x0;var _0x36cdca=_0x8fb1[_0x21a02a];return _0x36cdca;};'use strict';var _=require(_0x18fb('0x0'));var md5=require(_0x18fb('0x1'));var util=require('util');var Redis=require(_0x18fb('0x2'));var config=require(_0x18fb('0x3'));config['redis']=_[_0x18fb('0x4')](config[_0x18fb('0x5')],{'host':_0x18fb('0x6'),'port':0x18eb});var io=require(_0x18fb('0x7'))(new Redis(config[_0x18fb('0x5')]));function MailQueue(_0x27afe9){this['id']=_0x27afe9['id']||0x0;this['name']=_0x27afe9['name']||'';this['timeout']=_0x27afe9[_0x18fb('0x8')]||0xa;this[_0x18fb('0x9')]=_0x27afe9[_0x18fb('0x9')]||_0x18fb('0xa');this[_0x18fb('0xb')]=_0x27afe9[_0x18fb('0xb')];this['mapAgentsId']={};this[_0x18fb('0xc')]=0x0;this['md5']='';this[_0x18fb('0xd')]();this[_0x18fb('0xe')]();}MailQueue[_0x18fb('0xf')][_0x18fb('0xd')]=function(){var _0x4518b6=this['mapAgentsId'][_0x18fb('0x10')];this[_0x18fb('0x11')]=_['map'](this[_0x18fb('0xb')],'id');this['mapAgentsId']['_rr']=_0x4518b6;};MailQueue['prototype'][_0x18fb('0xe')]=function(){this[_0x18fb('0x12')]=0x0;this[_0x18fb('0x13')]=0x0;for(var _0x3db314=0x0;_0x3db314<this[_0x18fb('0xb')][_0x18fb('0x14')];_0x3db314+=0x1){if(this[_0x18fb('0xb')][_0x3db314][_0x18fb('0x15')]){this[_0x18fb('0x12')]+=0x1;}if(this[_0x18fb('0xb')][_0x3db314][_0x18fb('0x16')]){this[_0x18fb('0x13')]+=0x1;}}this[_0x18fb('0x17')]=this[_0x18fb('0x12')]-this[_0x18fb('0x13')];this[_0x18fb('0x17')]=this['available']>=0x0?this[_0x18fb('0x17')]:0x0;var _0x2eea95={'id':this['id'],'available':this[_0x18fb('0x17')],'loggedIn':this[_0x18fb('0x12')],'name':this[_0x18fb('0x18')],'paused':this['paused'],'waiting':this[_0x18fb('0xc')]};var _0x4a4a71=md5(JSON[_0x18fb('0x19')](_0x2eea95));if(this[_0x18fb('0x1')]!==_0x4a4a71){this[_0x18fb('0x1')]=_0x4a4a71;io['to'](util['format'](_0x18fb('0x1a'),_0x2eea95[_0x18fb('0x18')]))['emit']('mail_queue:save',_0x2eea95);}};module['exports']=MailQueue;