Built motion from commit (unavailable).|2.5.4
[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 _0xfcf8=['util','ioredis','../../../config/environment','redis','localhost','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype','map','updateRealtime','loggedIn','paused','length','online','available','stringify','format','whatsapp:queue:%s','emit','whatsapp_queue:save','exports','lodash','md5'];(function(_0x725a4c,_0x102507){var _0x37b2cc=function(_0x505fc9){while(--_0x505fc9){_0x725a4c['push'](_0x725a4c['shift']());}};_0x37b2cc(++_0x102507);}(_0xfcf8,0x8f));var _0x8fcf=function(_0x5bd426,_0x4878e5){_0x5bd426=_0x5bd426-0x0;var _0x23a7eb=_0xfcf8[_0x5bd426];return _0x23a7eb;};'use strict';var _=require(_0x8fcf('0x0'));var md5=require(_0x8fcf('0x1'));var util=require(_0x8fcf('0x2'));var Redis=require(_0x8fcf('0x3'));var config=require(_0x8fcf('0x4'));config[_0x8fcf('0x5')]=_['defaults'](config[_0x8fcf('0x5')],{'host':_0x8fcf('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function WhatsappQueue(_0x4487f7){this['id']=_0x4487f7['id']||0x0;this['name']=_0x4487f7[_0x8fcf('0x7')]||'';this[_0x8fcf('0x8')]=_0x4487f7[_0x8fcf('0x8')]||0xa;this[_0x8fcf('0x9')]=_0x4487f7[_0x8fcf('0x9')]||_0x8fcf('0xa');this[_0x8fcf('0xb')]=_0x4487f7['Agents'];this[_0x8fcf('0xc')]={};this[_0x8fcf('0xd')]=0x0;this[_0x8fcf('0x1')]='';this[_0x8fcf('0xe')]();this['updateRealtime']();}WhatsappQueue[_0x8fcf('0xf')][_0x8fcf('0xe')]=function(){var _0x50404f=this[_0x8fcf('0xc')]['_rr'];this[_0x8fcf('0xc')]=_[_0x8fcf('0x10')](this[_0x8fcf('0xb')],'id');this['mapAgentsId']['_rr']=_0x50404f;};WhatsappQueue[_0x8fcf('0xf')][_0x8fcf('0x11')]=function(){this[_0x8fcf('0x12')]=0x0;this[_0x8fcf('0x13')]=0x0;for(var _0x298697=0x0;_0x298697<this[_0x8fcf('0xb')][_0x8fcf('0x14')];_0x298697+=0x1){if(this[_0x8fcf('0xb')][_0x298697][_0x8fcf('0x15')]){this[_0x8fcf('0x12')]+=0x1;}if(this[_0x8fcf('0xb')][_0x298697]['whatsappPause']){this[_0x8fcf('0x13')]+=0x1;}}this[_0x8fcf('0x16')]=this[_0x8fcf('0x12')]-this['paused'];this['available']=this[_0x8fcf('0x16')]>=0x0?this[_0x8fcf('0x16')]:0x0;var _0x13008a={'id':this['id'],'available':this[_0x8fcf('0x16')],'loggedIn':this[_0x8fcf('0x12')],'name':this['name'],'paused':this[_0x8fcf('0x13')],'waiting':this[_0x8fcf('0xd')]};var _0x344bb7=md5(JSON[_0x8fcf('0x17')](_0x13008a));if(this[_0x8fcf('0x1')]!==_0x344bb7){this[_0x8fcf('0x1')]=_0x344bb7;io['to'](util[_0x8fcf('0x18')](_0x8fcf('0x19'),_0x13008a[_0x8fcf('0x7')]))[_0x8fcf('0x1a')](_0x8fcf('0x1b'),_0x13008a);}};module[_0x8fcf('0x1c')]=WhatsappQueue;