Built motion from commit 20b39a97.|2.6.29
[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 _0x9e85=['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','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','length','online','whatsappPause','paused','available','waiting','stringify'];(function(_0x58dc03,_0x1c0b28){var _0x2f14bb=function(_0x29e209){while(--_0x29e209){_0x58dc03['push'](_0x58dc03['shift']());}};_0x2f14bb(++_0x1c0b28);}(_0x9e85,0x1d3));var _0x59e8=function(_0xf25c17,_0x288f2c){_0xf25c17=_0xf25c17-0x0;var _0x429736=_0x9e85[_0xf25c17];return _0x429736;};'use strict';var _=require(_0x59e8('0x0'));var md5=require(_0x59e8('0x1'));var util=require(_0x59e8('0x2'));var Redis=require(_0x59e8('0x3'));var config=require(_0x59e8('0x4'));config[_0x59e8('0x5')]=_[_0x59e8('0x6')](config[_0x59e8('0x5')],{'host':_0x59e8('0x7'),'port':0x18eb});var io=require(_0x59e8('0x8'))(new Redis(config[_0x59e8('0x5')]));function WhatsappQueue(_0xca33cd){this['id']=_0xca33cd['id']||0x0;this[_0x59e8('0x9')]=_0xca33cd[_0x59e8('0x9')]||'';this[_0x59e8('0xa')]=_0xca33cd[_0x59e8('0xa')]||0xa;this[_0x59e8('0xb')]=_0xca33cd[_0x59e8('0xb')]||_0x59e8('0xc');this[_0x59e8('0xd')]=_0xca33cd['Agents'];this[_0x59e8('0xe')]={};this['waiting']=0x0;this['md5']='';this[_0x59e8('0xf')]();this[_0x59e8('0x10')]();}WhatsappQueue[_0x59e8('0x11')][_0x59e8('0xf')]=function(){var _0x4b8be4=this[_0x59e8('0xe')][_0x59e8('0x12')];this[_0x59e8('0xe')]=_[_0x59e8('0x13')](this[_0x59e8('0xd')],'id');this[_0x59e8('0xe')][_0x59e8('0x12')]=_0x4b8be4;};WhatsappQueue['prototype'][_0x59e8('0x10')]=function(){this[_0x59e8('0x14')]=0x0;this['paused']=0x0;for(var _0x399cad=0x0;_0x399cad<this[_0x59e8('0xd')][_0x59e8('0x15')];_0x399cad+=0x1){if(this[_0x59e8('0xd')][_0x399cad][_0x59e8('0x16')]){this['loggedIn']+=0x1;}if(this[_0x59e8('0xd')][_0x399cad][_0x59e8('0x17')]){this[_0x59e8('0x18')]+=0x1;}}this[_0x59e8('0x19')]=this[_0x59e8('0x14')]-this[_0x59e8('0x18')];this[_0x59e8('0x19')]=this[_0x59e8('0x19')]>=0x0?this['available']:0x0;var _0x21c661={'id':this['id'],'available':this[_0x59e8('0x19')],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this[_0x59e8('0x18')],'waiting':this[_0x59e8('0x1a')]};var _0x17fda0=md5(JSON[_0x59e8('0x1b')](_0x21c661));if(this[_0x59e8('0x1')]!==_0x17fda0){this[_0x59e8('0x1')]=_0x17fda0;io['to'](util[_0x59e8('0x1c')](_0x59e8('0x1d'),_0x21c661[_0x59e8('0x9')]))[_0x59e8('0x1e')](_0x59e8('0x1f'),_0x21c661);}};module[_0x59e8('0x20')]=WhatsappQueue;