Built motion from commit (unavailable).|2.5.11
[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 _0xb827=['name','timeout','strategy','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','Agents','loggedIn','paused','length','online','mailPause','available','format','mail:queue:%s','emit','exports','lodash','md5','util','ioredis','redis','defaults','localhost','socket.io-emitter'];(function(_0xaf1c01,_0x32df03){var _0x2f2fe8=function(_0x374ffc){while(--_0x374ffc){_0xaf1c01['push'](_0xaf1c01['shift']());}};_0x2f2fe8(++_0x32df03);}(_0xb827,0x1ab));var _0x7b82=function(_0xad1f42,_0x2df520){_0xad1f42=_0xad1f42-0x0;var _0x109709=_0xb827[_0xad1f42];return _0x109709;};'use strict';var _=require(_0x7b82('0x0'));var md5=require(_0x7b82('0x1'));var util=require(_0x7b82('0x2'));var Redis=require(_0x7b82('0x3'));var config=require('../../../config/environment');config[_0x7b82('0x4')]=_[_0x7b82('0x5')](config[_0x7b82('0x4')],{'host':_0x7b82('0x6'),'port':0x18eb});var io=require(_0x7b82('0x7'))(new Redis(config['redis']));function MailQueue(_0x22deb7){this['id']=_0x22deb7['id']||0x0;this[_0x7b82('0x8')]=_0x22deb7[_0x7b82('0x8')]||'';this[_0x7b82('0x9')]=_0x22deb7[_0x7b82('0x9')]||0xa;this['strategy']=_0x22deb7[_0x7b82('0xa')]||'beepall';this['Agents']=_0x22deb7['Agents'];this[_0x7b82('0xb')]={};this[_0x7b82('0xc')]=0x0;this[_0x7b82('0x1')]='';this[_0x7b82('0xd')]();this[_0x7b82('0xe')]();}MailQueue[_0x7b82('0xf')][_0x7b82('0xd')]=function(){var _0x379982=this[_0x7b82('0xb')][_0x7b82('0x10')];this[_0x7b82('0xb')]=_[_0x7b82('0x11')](this[_0x7b82('0x12')],'id');this[_0x7b82('0xb')]['_rr']=_0x379982;};MailQueue['prototype']['updateRealtime']=function(){this[_0x7b82('0x13')]=0x0;this[_0x7b82('0x14')]=0x0;for(var _0x13dfc3=0x0;_0x13dfc3<this[_0x7b82('0x12')][_0x7b82('0x15')];_0x13dfc3+=0x1){if(this[_0x7b82('0x12')][_0x13dfc3][_0x7b82('0x16')]){this['loggedIn']+=0x1;}if(this[_0x7b82('0x12')][_0x13dfc3][_0x7b82('0x17')]){this[_0x7b82('0x14')]+=0x1;}}this['available']=this[_0x7b82('0x13')]-this['paused'];this['available']=this[_0x7b82('0x18')]>=0x0?this[_0x7b82('0x18')]:0x0;var _0x4d1b34={'id':this['id'],'available':this[_0x7b82('0x18')],'loggedIn':this[_0x7b82('0x13')],'name':this[_0x7b82('0x8')],'paused':this[_0x7b82('0x14')],'waiting':this[_0x7b82('0xc')]};var _0x12dea8=md5(JSON['stringify'](_0x4d1b34));if(this[_0x7b82('0x1')]!==_0x12dea8){this[_0x7b82('0x1')]=_0x12dea8;io['to'](util[_0x7b82('0x19')](_0x7b82('0x1a'),_0x4d1b34[_0x7b82('0x8')]))[_0x7b82('0x1b')]('mail_queue:save',_0x4d1b34);}};module[_0x7b82('0x1c')]=MailQueue;