645d2818d990c60f3bd7f360a5e02363fe49d2c5
[motion2.git] / server / services / routing / model / whatsappQueue.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 _0x7211=['Agents','mapAgentsId','waiting','updateRouting','prototype','map','_rr','loggedIn','paused','length','whatsappPause','available','stringify','whatsapp:queue:%s','whatsapp_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall'];(function(_0x126558,_0x143c9a){var _0x1f6d14=function(_0x2b0eea){while(--_0x2b0eea){_0x126558['push'](_0x126558['shift']());}};_0x1f6d14(++_0x143c9a);}(_0x7211,0x115));var _0x1721=function(_0xc4a1ee,_0x13f2d1){_0xc4a1ee=_0xc4a1ee-0x0;var _0x28675e=_0x7211[_0xc4a1ee];return _0x28675e;};'use strict';var _=require(_0x1721('0x0'));var md5=require(_0x1721('0x1'));var util=require(_0x1721('0x2'));var Redis=require(_0x1721('0x3'));var config=require(_0x1721('0x4'));config[_0x1721('0x5')]=_[_0x1721('0x6')](config[_0x1721('0x5')],{'host':_0x1721('0x7'),'port':0x18eb});var io=require(_0x1721('0x8'))(new Redis(config[_0x1721('0x5')]));function WhatsappQueue(_0x5452d6){this['id']=_0x5452d6['id']||0x0;this[_0x1721('0x9')]=_0x5452d6[_0x1721('0x9')]||'';this[_0x1721('0xa')]=_0x5452d6[_0x1721('0xa')]||0xa;this[_0x1721('0xb')]=_0x5452d6[_0x1721('0xb')]||_0x1721('0xc');this[_0x1721('0xd')]=_0x5452d6['Agents'];this[_0x1721('0xe')]={};this[_0x1721('0xf')]=0x0;this[_0x1721('0x1')]='';this[_0x1721('0x10')]();this['updateRealtime']();}WhatsappQueue[_0x1721('0x11')][_0x1721('0x10')]=function(){var _0x61c7fe=this[_0x1721('0xe')]['_rr'];this['mapAgentsId']=_[_0x1721('0x12')](this['Agents'],'id');this[_0x1721('0xe')][_0x1721('0x13')]=_0x61c7fe;};WhatsappQueue[_0x1721('0x11')]['updateRealtime']=function(){this[_0x1721('0x14')]=0x0;this[_0x1721('0x15')]=0x0;for(var _0x245ec0=0x0;_0x245ec0<this[_0x1721('0xd')][_0x1721('0x16')];_0x245ec0+=0x1){if(this[_0x1721('0xd')][_0x245ec0]['online']){this[_0x1721('0x14')]+=0x1;}if(this['Agents'][_0x245ec0][_0x1721('0x17')]){this[_0x1721('0x15')]+=0x1;}}this['available']=this[_0x1721('0x14')]-this['paused'];this[_0x1721('0x18')]=this[_0x1721('0x18')]>=0x0?this[_0x1721('0x18')]:0x0;var _0x110e17={'id':this['id'],'available':this[_0x1721('0x18')],'loggedIn':this['loggedIn'],'name':this[_0x1721('0x9')],'paused':this[_0x1721('0x15')],'waiting':this[_0x1721('0xf')]};var _0x5a6bd6=md5(JSON[_0x1721('0x19')](_0x110e17));if(this[_0x1721('0x1')]!==_0x5a6bd6){this['md5']=_0x5a6bd6;io['to'](util['format'](_0x1721('0x1a'),_0x110e17[_0x1721('0x9')]))['emit'](_0x1721('0x1b'),_0x110e17);}};module[_0x1721('0x1c')]=WhatsappQueue;