0873568241387f7258b94fd957aa6c66887cae47
[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 _0x5a41=['updateRealtime','prototype','map','_rr','paused','online','mailPause','available','loggedIn','stringify','mail:queue:%s','emit','mail_queue:save','lodash','md5','util','ioredis','../../../config/environment','defaults','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting'];(function(_0x580576,_0x2f107d){var _0x3f55a0=function(_0x2e180b){while(--_0x2e180b){_0x580576['push'](_0x580576['shift']());}};_0x3f55a0(++_0x2f107d);}(_0x5a41,0x1b1));var _0x15a4=function(_0x8d3262,_0x439e73){_0x8d3262=_0x8d3262-0x0;var _0x45561c=_0x5a41[_0x8d3262];return _0x45561c;};'use strict';var _=require(_0x15a4('0x0'));var md5=require(_0x15a4('0x1'));var util=require(_0x15a4('0x2'));var Redis=require(_0x15a4('0x3'));var config=require(_0x15a4('0x4'));config['redis']=_[_0x15a4('0x5')](config[_0x15a4('0x6')],{'host':_0x15a4('0x7'),'port':0x18eb});var io=require(_0x15a4('0x8'))(new Redis(config[_0x15a4('0x6')]));function MailQueue(_0x5c03a6){this['id']=_0x5c03a6['id']||0x0;this[_0x15a4('0x9')]=_0x5c03a6[_0x15a4('0x9')]||'';this[_0x15a4('0xa')]=_0x5c03a6['timeout']||0xa;this[_0x15a4('0xb')]=_0x5c03a6[_0x15a4('0xb')]||_0x15a4('0xc');this[_0x15a4('0xd')]=_0x5c03a6[_0x15a4('0xd')];this[_0x15a4('0xe')]={};this[_0x15a4('0xf')]=0x0;this['md5']='';this[_0x15a4('0x10')]();this[_0x15a4('0x11')]();}MailQueue[_0x15a4('0x12')]['updateRouting']=function(){var _0x2f042e=this[_0x15a4('0xe')]['_rr'];this['mapAgentsId']=_[_0x15a4('0x13')](this[_0x15a4('0xd')],'id');this[_0x15a4('0xe')][_0x15a4('0x14')]=_0x2f042e;};MailQueue['prototype'][_0x15a4('0x11')]=function(){this['loggedIn']=0x0;this[_0x15a4('0x15')]=0x0;for(var _0x12af39=0x0;_0x12af39<this[_0x15a4('0xd')]['length'];_0x12af39+=0x1){if(this[_0x15a4('0xd')][_0x12af39][_0x15a4('0x16')]){this['loggedIn']+=0x1;}if(this['Agents'][_0x12af39][_0x15a4('0x17')]){this[_0x15a4('0x15')]+=0x1;}}this[_0x15a4('0x18')]=this[_0x15a4('0x19')]-this[_0x15a4('0x15')];this['available']=this[_0x15a4('0x18')]>=0x0?this['available']:0x0;var _0x257a0c={'id':this['id'],'available':this['available'],'loggedIn':this[_0x15a4('0x19')],'name':this[_0x15a4('0x9')],'paused':this[_0x15a4('0x15')],'waiting':this[_0x15a4('0xf')]};var _0x51301a=md5(JSON[_0x15a4('0x1a')](_0x257a0c));if(this[_0x15a4('0x1')]!==_0x51301a){this['md5']=_0x51301a;io['to'](util['format'](_0x15a4('0x1b'),_0x257a0c[_0x15a4('0x9')]))[_0x15a4('0x1c')](_0x15a4('0x1d'),_0x257a0c);}};module['exports']=MailQueue;