Built motion from commit (unavailable).|2.4.17
[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 _0x1bd4=['prototype','mapAgentsId','map','_rr','loggedIn','paused','length','online','mailPause','available','stringify','mail:queue:%s','emit','exports','lodash','md5','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','updateRouting','updateRealtime'];(function(_0x3d2d6f,_0x368872){var _0x5c0022=function(_0x408819){while(--_0x408819){_0x3d2d6f['push'](_0x3d2d6f['shift']());}};_0x5c0022(++_0x368872);}(_0x1bd4,0xf6));var _0x41bd=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x1bd4[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x41bd('0x0'));var md5=require(_0x41bd('0x1'));var util=require('util');var Redis=require(_0x41bd('0x2'));var config=require('../../../config/environment');config[_0x41bd('0x3')]=_[_0x41bd('0x4')](config['redis'],{'host':_0x41bd('0x5'),'port':0x18eb});var io=require(_0x41bd('0x6'))(new Redis(config[_0x41bd('0x3')]));function MailQueue(_0x16a5b9){this['id']=_0x16a5b9['id']||0x0;this[_0x41bd('0x7')]=_0x16a5b9[_0x41bd('0x7')]||'';this[_0x41bd('0x8')]=_0x16a5b9[_0x41bd('0x8')]||0xa;this[_0x41bd('0x9')]=_0x16a5b9[_0x41bd('0x9')]||_0x41bd('0xa');this['Agents']=_0x16a5b9[_0x41bd('0xb')];this['mapAgentsId']={};this[_0x41bd('0xc')]=0x0;this['md5']='';this[_0x41bd('0xd')]();this[_0x41bd('0xe')]();}MailQueue[_0x41bd('0xf')][_0x41bd('0xd')]=function(){var _0x1a4c1e=this[_0x41bd('0x10')]['_rr'];this[_0x41bd('0x10')]=_[_0x41bd('0x11')](this['Agents'],'id');this['mapAgentsId'][_0x41bd('0x12')]=_0x1a4c1e;};MailQueue[_0x41bd('0xf')]['updateRealtime']=function(){this[_0x41bd('0x13')]=0x0;this[_0x41bd('0x14')]=0x0;for(var _0x5001c6=0x0;_0x5001c6<this['Agents'][_0x41bd('0x15')];_0x5001c6+=0x1){if(this['Agents'][_0x5001c6][_0x41bd('0x16')]){this[_0x41bd('0x13')]+=0x1;}if(this[_0x41bd('0xb')][_0x5001c6][_0x41bd('0x17')]){this[_0x41bd('0x14')]+=0x1;}}this[_0x41bd('0x18')]=this[_0x41bd('0x13')]-this['paused'];this[_0x41bd('0x18')]=this['available']>=0x0?this['available']:0x0;var _0xa7d2fb={'id':this['id'],'available':this[_0x41bd('0x18')],'loggedIn':this['loggedIn'],'name':this[_0x41bd('0x7')],'paused':this['paused'],'waiting':this['waiting']};var _0x3c8c0d=md5(JSON[_0x41bd('0x19')](_0xa7d2fb));if(this['md5']!==_0x3c8c0d){this['md5']=_0x3c8c0d;io['to'](util['format'](_0x41bd('0x1a'),_0xa7d2fb[_0x41bd('0x7')]))[_0x41bd('0x1b')]('mail_queue:save',_0xa7d2fb);}};module[_0x41bd('0x1c')]=MailQueue;