Built motion from commit fe909640.|2.6.8
[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 _0xca37=['updateRouting','map','loggedIn','paused','length','online','mailPause','available','stringify','format','mail:queue:%s','emit','mail_queue:save','lodash','md5','util','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRealtime','prototype'];(function(_0x462999,_0x24d200){var _0x4b1366=function(_0x1fa353){while(--_0x1fa353){_0x462999['push'](_0x462999['shift']());}};_0x4b1366(++_0x24d200);}(_0xca37,0x1dd));var _0x7ca3=function(_0x2f07aa,_0x36bdb9){_0x2f07aa=_0x2f07aa-0x0;var _0x20a1f2=_0xca37[_0x2f07aa];return _0x20a1f2;};'use strict';var _=require(_0x7ca3('0x0'));var md5=require(_0x7ca3('0x1'));var util=require(_0x7ca3('0x2'));var Redis=require('ioredis');var config=require('../../../config/environment');config[_0x7ca3('0x3')]=_[_0x7ca3('0x4')](config[_0x7ca3('0x3')],{'host':_0x7ca3('0x5'),'port':0x18eb});var io=require(_0x7ca3('0x6'))(new Redis(config[_0x7ca3('0x3')]));function MailQueue(_0x4174c5){this['id']=_0x4174c5['id']||0x0;this[_0x7ca3('0x7')]=_0x4174c5[_0x7ca3('0x7')]||'';this[_0x7ca3('0x8')]=_0x4174c5[_0x7ca3('0x8')]||0xa;this[_0x7ca3('0x9')]=_0x4174c5[_0x7ca3('0x9')]||_0x7ca3('0xa');this[_0x7ca3('0xb')]=_0x4174c5['Agents'];this[_0x7ca3('0xc')]={};this[_0x7ca3('0xd')]=0x0;this[_0x7ca3('0x1')]='';this['updateRouting']();this[_0x7ca3('0xe')]();}MailQueue[_0x7ca3('0xf')][_0x7ca3('0x10')]=function(){var _0x58ff17=this[_0x7ca3('0xc')]['_rr'];this[_0x7ca3('0xc')]=_[_0x7ca3('0x11')](this['Agents'],'id');this['mapAgentsId']['_rr']=_0x58ff17;};MailQueue[_0x7ca3('0xf')][_0x7ca3('0xe')]=function(){this[_0x7ca3('0x12')]=0x0;this[_0x7ca3('0x13')]=0x0;for(var _0x5e0df3=0x0;_0x5e0df3<this[_0x7ca3('0xb')][_0x7ca3('0x14')];_0x5e0df3+=0x1){if(this['Agents'][_0x5e0df3][_0x7ca3('0x15')]){this[_0x7ca3('0x12')]+=0x1;}if(this[_0x7ca3('0xb')][_0x5e0df3][_0x7ca3('0x16')]){this['paused']+=0x1;}}this[_0x7ca3('0x17')]=this['loggedIn']-this[_0x7ca3('0x13')];this[_0x7ca3('0x17')]=this['available']>=0x0?this[_0x7ca3('0x17')]:0x0;var _0x5753ba={'id':this['id'],'available':this[_0x7ca3('0x17')],'loggedIn':this['loggedIn'],'name':this[_0x7ca3('0x7')],'paused':this['paused'],'waiting':this[_0x7ca3('0xd')]};var _0x4ff4da=md5(JSON[_0x7ca3('0x18')](_0x5753ba));if(this[_0x7ca3('0x1')]!==_0x4ff4da){this['md5']=_0x4ff4da;io['to'](util[_0x7ca3('0x19')](_0x7ca3('0x1a'),_0x5753ba[_0x7ca3('0x7')]))[_0x7ca3('0x1b')](_0x7ca3('0x1c'),_0x5753ba);}};module['exports']=MailQueue;