1e4a9c38630dfd2ef21a8de4650924d5f042e614
[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 _0x343a=['Agents','updateRouting','prototype','_rr','mapAgentsId','updateRealtime','loggedIn','paused','online','whatsappPause','available','stringify','format','whatsapp:queue:%s','emit','whatsapp_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall'];(function(_0x228fdf,_0x29c8a6){var _0x4312b3=function(_0x307623){while(--_0x307623){_0x228fdf['push'](_0x228fdf['shift']());}};_0x4312b3(++_0x29c8a6);}(_0x343a,0x1f1));var _0xa343=function(_0x3b9dd4,_0xc1d496){_0x3b9dd4=_0x3b9dd4-0x0;var _0x321783=_0x343a[_0x3b9dd4];return _0x321783;};'use strict';var _=require(_0xa343('0x0'));var md5=require(_0xa343('0x1'));var util=require(_0xa343('0x2'));var Redis=require(_0xa343('0x3'));var config=require(_0xa343('0x4'));config[_0xa343('0x5')]=_[_0xa343('0x6')](config[_0xa343('0x5')],{'host':_0xa343('0x7'),'port':0x18eb});var io=require(_0xa343('0x8'))(new Redis(config[_0xa343('0x5')]));function WhatsappQueue(_0x4088ad){this['id']=_0x4088ad['id']||0x0;this[_0xa343('0x9')]=_0x4088ad[_0xa343('0x9')]||'';this['timeout']=_0x4088ad[_0xa343('0xa')]||0xa;this['strategy']=_0x4088ad[_0xa343('0xb')]||_0xa343('0xc');this[_0xa343('0xd')]=_0x4088ad[_0xa343('0xd')];this['mapAgentsId']={};this['waiting']=0x0;this[_0xa343('0x1')]='';this[_0xa343('0xe')]();this['updateRealtime']();}WhatsappQueue[_0xa343('0xf')]['updateRouting']=function(){var _0x3508ff=this['mapAgentsId'][_0xa343('0x10')];this[_0xa343('0x11')]=_['map'](this[_0xa343('0xd')],'id');this['mapAgentsId'][_0xa343('0x10')]=_0x3508ff;};WhatsappQueue[_0xa343('0xf')][_0xa343('0x12')]=function(){this[_0xa343('0x13')]=0x0;this[_0xa343('0x14')]=0x0;for(var _0x1d4170=0x0;_0x1d4170<this[_0xa343('0xd')]['length'];_0x1d4170+=0x1){if(this[_0xa343('0xd')][_0x1d4170][_0xa343('0x15')]){this[_0xa343('0x13')]+=0x1;}if(this[_0xa343('0xd')][_0x1d4170][_0xa343('0x16')]){this[_0xa343('0x14')]+=0x1;}}this[_0xa343('0x17')]=this['loggedIn']-this['paused'];this[_0xa343('0x17')]=this[_0xa343('0x17')]>=0x0?this[_0xa343('0x17')]:0x0;var _0x208f86={'id':this['id'],'available':this[_0xa343('0x17')],'loggedIn':this[_0xa343('0x13')],'name':this[_0xa343('0x9')],'paused':this[_0xa343('0x14')],'waiting':this['waiting']};var _0x38bcf0=md5(JSON[_0xa343('0x18')](_0x208f86));if(this['md5']!==_0x38bcf0){this['md5']=_0x38bcf0;io['to'](util[_0xa343('0x19')](_0xa343('0x1a'),_0x208f86[_0xa343('0x9')]))[_0xa343('0x1b')](_0xa343('0x1c'),_0x208f86);}};module[_0xa343('0x1d')]=WhatsappQueue;