812bb96512e5544b7c41a58399987e3fe2b3c7ed
[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 _0xb134=['redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','map','_rr','prototype','loggedIn','paused','length','online','mailPause','available','format','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','defaults'];(function(_0x50a0c2,_0x4befab){var _0x5ebadd=function(_0x3a3342){while(--_0x3a3342){_0x50a0c2['push'](_0x50a0c2['shift']());}};_0x5ebadd(++_0x4befab);}(_0xb134,0x17a));var _0x4b13=function(_0x255d5b,_0x4f6f35){_0x255d5b=_0x255d5b-0x0;var _0x3e141a=_0xb134[_0x255d5b];return _0x3e141a;};'use strict';var _=require(_0x4b13('0x0'));var md5=require(_0x4b13('0x1'));var util=require(_0x4b13('0x2'));var Redis=require(_0x4b13('0x3'));var config=require(_0x4b13('0x4'));config['redis']=_[_0x4b13('0x5')](config[_0x4b13('0x6')],{'host':_0x4b13('0x7'),'port':0x18eb});var io=require(_0x4b13('0x8'))(new Redis(config[_0x4b13('0x6')]));function MailQueue(_0x3715b9){this['id']=_0x3715b9['id']||0x0;this[_0x4b13('0x9')]=_0x3715b9[_0x4b13('0x9')]||'';this['timeout']=_0x3715b9[_0x4b13('0xa')]||0xa;this[_0x4b13('0xb')]=_0x3715b9[_0x4b13('0xb')]||_0x4b13('0xc');this[_0x4b13('0xd')]=_0x3715b9['Agents'];this[_0x4b13('0xe')]={};this[_0x4b13('0xf')]=0x0;this[_0x4b13('0x1')]='';this[_0x4b13('0x10')]();this[_0x4b13('0x11')]();}MailQueue['prototype'][_0x4b13('0x10')]=function(){var _0x2c0dcf=this[_0x4b13('0xe')]['_rr'];this[_0x4b13('0xe')]=_[_0x4b13('0x12')](this[_0x4b13('0xd')],'id');this[_0x4b13('0xe')][_0x4b13('0x13')]=_0x2c0dcf;};MailQueue[_0x4b13('0x14')]['updateRealtime']=function(){this[_0x4b13('0x15')]=0x0;this[_0x4b13('0x16')]=0x0;for(var _0x445a9e=0x0;_0x445a9e<this['Agents'][_0x4b13('0x17')];_0x445a9e+=0x1){if(this[_0x4b13('0xd')][_0x445a9e][_0x4b13('0x18')]){this[_0x4b13('0x15')]+=0x1;}if(this[_0x4b13('0xd')][_0x445a9e][_0x4b13('0x19')]){this[_0x4b13('0x16')]+=0x1;}}this[_0x4b13('0x1a')]=this[_0x4b13('0x15')]-this[_0x4b13('0x16')];this[_0x4b13('0x1a')]=this[_0x4b13('0x1a')]>=0x0?this[_0x4b13('0x1a')]:0x0;var _0x4eedf8={'id':this['id'],'available':this[_0x4b13('0x1a')],'loggedIn':this[_0x4b13('0x15')],'name':this[_0x4b13('0x9')],'paused':this[_0x4b13('0x16')],'waiting':this[_0x4b13('0xf')]};var _0x256e08=md5(JSON['stringify'](_0x4eedf8));if(this[_0x4b13('0x1')]!==_0x256e08){this[_0x4b13('0x1')]=_0x256e08;io['to'](util[_0x4b13('0x1b')](_0x4b13('0x1c'),_0x4eedf8['name']))[_0x4b13('0x1d')](_0x4b13('0x1e'),_0x4eedf8);}};module[_0x4b13('0x1f')]=MailQueue;