Built motion from commit (unavailable).|2.6.0
[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 _0xec33=['paused','available','stringify','format','mail:queue:%s','emit','mail_queue:save','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','map','_rr','loggedIn','mailPause'];(function(_0x3d3a71,_0x4b46b8){var _0x1e4baf=function(_0x43513f){while(--_0x43513f){_0x3d3a71['push'](_0x3d3a71['shift']());}};_0x1e4baf(++_0x4b46b8);}(_0xec33,0x1f4));var _0x3ec3=function(_0x45d6b8,_0x17469f){_0x45d6b8=_0x45d6b8-0x0;var _0x45dd52=_0xec33[_0x45d6b8];return _0x45dd52;};'use strict';var _=require(_0x3ec3('0x0'));var md5=require(_0x3ec3('0x1'));var util=require(_0x3ec3('0x2'));var Redis=require(_0x3ec3('0x3'));var config=require(_0x3ec3('0x4'));config[_0x3ec3('0x5')]=_[_0x3ec3('0x6')](config['redis'],{'host':_0x3ec3('0x7'),'port':0x18eb});var io=require(_0x3ec3('0x8'))(new Redis(config[_0x3ec3('0x5')]));function MailQueue(_0xbce369){this['id']=_0xbce369['id']||0x0;this['name']=_0xbce369[_0x3ec3('0x9')]||'';this['timeout']=_0xbce369['timeout']||0xa;this[_0x3ec3('0xa')]=_0xbce369[_0x3ec3('0xa')]||_0x3ec3('0xb');this['Agents']=_0xbce369[_0x3ec3('0xc')];this[_0x3ec3('0xd')]={};this[_0x3ec3('0xe')]=0x0;this['md5']='';this[_0x3ec3('0xf')]();this[_0x3ec3('0x10')]();}MailQueue[_0x3ec3('0x11')][_0x3ec3('0xf')]=function(){var _0x11225f=this[_0x3ec3('0xd')]['_rr'];this[_0x3ec3('0xd')]=_[_0x3ec3('0x12')](this[_0x3ec3('0xc')],'id');this[_0x3ec3('0xd')][_0x3ec3('0x13')]=_0x11225f;};MailQueue[_0x3ec3('0x11')][_0x3ec3('0x10')]=function(){this[_0x3ec3('0x14')]=0x0;this['paused']=0x0;for(var _0x42736b=0x0;_0x42736b<this[_0x3ec3('0xc')]['length'];_0x42736b+=0x1){if(this[_0x3ec3('0xc')][_0x42736b]['online']){this[_0x3ec3('0x14')]+=0x1;}if(this['Agents'][_0x42736b][_0x3ec3('0x15')]){this[_0x3ec3('0x16')]+=0x1;}}this['available']=this['loggedIn']-this['paused'];this[_0x3ec3('0x17')]=this['available']>=0x0?this[_0x3ec3('0x17')]:0x0;var _0x1a4017={'id':this['id'],'available':this[_0x3ec3('0x17')],'loggedIn':this[_0x3ec3('0x14')],'name':this[_0x3ec3('0x9')],'paused':this[_0x3ec3('0x16')],'waiting':this[_0x3ec3('0xe')]};var _0x5e2afb=md5(JSON[_0x3ec3('0x18')](_0x1a4017));if(this[_0x3ec3('0x1')]!==_0x5e2afb){this[_0x3ec3('0x1')]=_0x5e2afb;io['to'](util[_0x3ec3('0x19')](_0x3ec3('0x1a'),_0x1a4017[_0x3ec3('0x9')]))[_0x3ec3('0x1b')](_0x3ec3('0x1c'),_0x1a4017);}};module['exports']=MailQueue;