Built motion from commit 0415ced0.|2.6.28
[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 _0xd23f=['online','mailPause','available','stringify','format','emit','mail_queue:save','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','map','updateRealtime','loggedIn','paused'];(function(_0xa846cd,_0x54e7d7){var _0x2144fb=function(_0x59d453){while(--_0x59d453){_0xa846cd['push'](_0xa846cd['shift']());}};_0x2144fb(++_0x54e7d7);}(_0xd23f,0x151));var _0xfd23=function(_0x432682,_0x253044){_0x432682=_0x432682-0x0;var _0x463d05=_0xd23f[_0x432682];return _0x463d05;};'use strict';var _=require(_0xfd23('0x0'));var md5=require(_0xfd23('0x1'));var util=require(_0xfd23('0x2'));var Redis=require(_0xfd23('0x3'));var config=require(_0xfd23('0x4'));config[_0xfd23('0x5')]=_[_0xfd23('0x6')](config[_0xfd23('0x5')],{'host':_0xfd23('0x7'),'port':0x18eb});var io=require(_0xfd23('0x8'))(new Redis(config['redis']));function MailQueue(_0xbb7c8d){this['id']=_0xbb7c8d['id']||0x0;this['name']=_0xbb7c8d[_0xfd23('0x9')]||'';this['timeout']=_0xbb7c8d[_0xfd23('0xa')]||0xa;this['strategy']=_0xbb7c8d[_0xfd23('0xb')]||_0xfd23('0xc');this[_0xfd23('0xd')]=_0xbb7c8d[_0xfd23('0xd')];this[_0xfd23('0xe')]={};this[_0xfd23('0xf')]=0x0;this['md5']='';this[_0xfd23('0x10')]();this['updateRealtime']();}MailQueue[_0xfd23('0x11')][_0xfd23('0x10')]=function(){var _0x2bda40=this[_0xfd23('0xe')][_0xfd23('0x12')];this['mapAgentsId']=_[_0xfd23('0x13')](this['Agents'],'id');this['mapAgentsId'][_0xfd23('0x12')]=_0x2bda40;};MailQueue[_0xfd23('0x11')][_0xfd23('0x14')]=function(){this[_0xfd23('0x15')]=0x0;this[_0xfd23('0x16')]=0x0;for(var _0x229be5=0x0;_0x229be5<this[_0xfd23('0xd')]['length'];_0x229be5+=0x1){if(this['Agents'][_0x229be5][_0xfd23('0x17')]){this[_0xfd23('0x15')]+=0x1;}if(this[_0xfd23('0xd')][_0x229be5][_0xfd23('0x18')]){this[_0xfd23('0x16')]+=0x1;}}this[_0xfd23('0x19')]=this[_0xfd23('0x15')]-this[_0xfd23('0x16')];this[_0xfd23('0x19')]=this[_0xfd23('0x19')]>=0x0?this[_0xfd23('0x19')]:0x0;var _0x2d0e29={'id':this['id'],'available':this['available'],'loggedIn':this[_0xfd23('0x15')],'name':this[_0xfd23('0x9')],'paused':this[_0xfd23('0x16')],'waiting':this[_0xfd23('0xf')]};var _0x4366f8=md5(JSON[_0xfd23('0x1a')](_0x2d0e29));if(this[_0xfd23('0x1')]!==_0x4366f8){this[_0xfd23('0x1')]=_0x4366f8;io['to'](util[_0xfd23('0x1b')]('mail:queue:%s',_0x2d0e29[_0xfd23('0x9')]))[_0xfd23('0x1c')](_0xfd23('0x1d'),_0x2d0e29);}};module['exports']=MailQueue;