Built motion from commit a61a4a20.|2.5.46
[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 _0xcfb3=['emit','mail_queue:save','exports','lodash','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','length','online','mailPause','available','paused','md5','mail:queue:%s'];(function(_0x347948,_0x20c689){var _0x4ade4e=function(_0x51d677){while(--_0x51d677){_0x347948['push'](_0x347948['shift']());}};_0x4ade4e(++_0x20c689);}(_0xcfb3,0x177));var _0x3cfb=function(_0xc5af65,_0x1fdb3d){_0xc5af65=_0xc5af65-0x0;var _0x5be8ed=_0xcfb3[_0xc5af65];return _0x5be8ed;};'use strict';var _=require(_0x3cfb('0x0'));var md5=require('md5');var util=require(_0x3cfb('0x1'));var Redis=require(_0x3cfb('0x2'));var config=require(_0x3cfb('0x3'));config[_0x3cfb('0x4')]=_[_0x3cfb('0x5')](config[_0x3cfb('0x4')],{'host':_0x3cfb('0x6'),'port':0x18eb});var io=require(_0x3cfb('0x7'))(new Redis(config['redis']));function MailQueue(_0x463b7d){this['id']=_0x463b7d['id']||0x0;this[_0x3cfb('0x8')]=_0x463b7d['name']||'';this[_0x3cfb('0x9')]=_0x463b7d[_0x3cfb('0x9')]||0xa;this[_0x3cfb('0xa')]=_0x463b7d[_0x3cfb('0xa')]||_0x3cfb('0xb');this[_0x3cfb('0xc')]=_0x463b7d['Agents'];this[_0x3cfb('0xd')]={};this[_0x3cfb('0xe')]=0x0;this['md5']='';this[_0x3cfb('0xf')]();this[_0x3cfb('0x10')]();}MailQueue[_0x3cfb('0x11')][_0x3cfb('0xf')]=function(){var _0x46f460=this['mapAgentsId'][_0x3cfb('0x12')];this[_0x3cfb('0xd')]=_[_0x3cfb('0x13')](this['Agents'],'id');this[_0x3cfb('0xd')][_0x3cfb('0x12')]=_0x46f460;};MailQueue[_0x3cfb('0x11')][_0x3cfb('0x10')]=function(){this[_0x3cfb('0x14')]=0x0;this['paused']=0x0;for(var _0x3e0fae=0x0;_0x3e0fae<this[_0x3cfb('0xc')][_0x3cfb('0x15')];_0x3e0fae+=0x1){if(this[_0x3cfb('0xc')][_0x3e0fae][_0x3cfb('0x16')]){this[_0x3cfb('0x14')]+=0x1;}if(this[_0x3cfb('0xc')][_0x3e0fae][_0x3cfb('0x17')]){this['paused']+=0x1;}}this[_0x3cfb('0x18')]=this[_0x3cfb('0x14')]-this[_0x3cfb('0x19')];this[_0x3cfb('0x18')]=this[_0x3cfb('0x18')]>=0x0?this[_0x3cfb('0x18')]:0x0;var _0x2a2e8e={'id':this['id'],'available':this['available'],'loggedIn':this[_0x3cfb('0x14')],'name':this[_0x3cfb('0x8')],'paused':this['paused'],'waiting':this[_0x3cfb('0xe')]};var _0x52511d=md5(JSON['stringify'](_0x2a2e8e));if(this[_0x3cfb('0x1a')]!==_0x52511d){this[_0x3cfb('0x1a')]=_0x52511d;io['to'](util['format'](_0x3cfb('0x1b'),_0x2a2e8e[_0x3cfb('0x8')]))[_0x3cfb('0x1c')](_0x3cfb('0x1d'),_0x2a2e8e);}};module[_0x3cfb('0x1e')]=MailQueue;