Built motion from commit 753c950e.|2.5.42
[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 _0x408f=['redis','defaults','localhost','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRealtime','prototype','_rr','map','paused','length','loggedIn','mailPause','available','stringify','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment'];(function(_0x45ade7,_0x237b70){var _0x4d70ce=function(_0x534690){while(--_0x534690){_0x45ade7['push'](_0x45ade7['shift']());}};_0x4d70ce(++_0x237b70);}(_0x408f,0xdb));var _0xf408=function(_0x3c75c2,_0x1daec2){_0x3c75c2=_0x3c75c2-0x0;var _0x700e18=_0x408f[_0x3c75c2];return _0x700e18;};'use strict';var _=require(_0xf408('0x0'));var md5=require(_0xf408('0x1'));var util=require(_0xf408('0x2'));var Redis=require(_0xf408('0x3'));var config=require(_0xf408('0x4'));config[_0xf408('0x5')]=_[_0xf408('0x6')](config[_0xf408('0x5')],{'host':_0xf408('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xf408('0x5')]));function MailQueue(_0x23f53f){this['id']=_0x23f53f['id']||0x0;this[_0xf408('0x8')]=_0x23f53f['name']||'';this['timeout']=_0x23f53f[_0xf408('0x9')]||0xa;this['strategy']=_0x23f53f[_0xf408('0xa')]||'beepall';this[_0xf408('0xb')]=_0x23f53f[_0xf408('0xb')];this[_0xf408('0xc')]={};this[_0xf408('0xd')]=0x0;this['md5']='';this['updateRouting']();this[_0xf408('0xe')]();}MailQueue[_0xf408('0xf')]['updateRouting']=function(){var _0x822435=this['mapAgentsId'][_0xf408('0x10')];this[_0xf408('0xc')]=_[_0xf408('0x11')](this['Agents'],'id');this['mapAgentsId'][_0xf408('0x10')]=_0x822435;};MailQueue['prototype'][_0xf408('0xe')]=function(){this['loggedIn']=0x0;this[_0xf408('0x12')]=0x0;for(var _0x24a941=0x0;_0x24a941<this['Agents'][_0xf408('0x13')];_0x24a941+=0x1){if(this['Agents'][_0x24a941]['online']){this[_0xf408('0x14')]+=0x1;}if(this[_0xf408('0xb')][_0x24a941][_0xf408('0x15')]){this[_0xf408('0x12')]+=0x1;}}this[_0xf408('0x16')]=this[_0xf408('0x14')]-this[_0xf408('0x12')];this[_0xf408('0x16')]=this[_0xf408('0x16')]>=0x0?this[_0xf408('0x16')]:0x0;var _0x3f9761={'id':this['id'],'available':this[_0xf408('0x16')],'loggedIn':this[_0xf408('0x14')],'name':this[_0xf408('0x8')],'paused':this[_0xf408('0x12')],'waiting':this[_0xf408('0xd')]};var _0x57556f=md5(JSON[_0xf408('0x17')](_0x3f9761));if(this['md5']!==_0x57556f){this[_0xf408('0x1')]=_0x57556f;io['to'](util['format'](_0xf408('0x18'),_0x3f9761[_0xf408('0x8')]))[_0xf408('0x19')](_0xf408('0x1a'),_0x3f9761);}};module[_0xf408('0x1b')]=MailQueue;