Built motion from commit 3e059bc2.|2.5.32
[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 _0xb542=['whatsapp:queue:%s','whatsapp_queue:save','exports','lodash','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length','online','available','waiting','md5'];(function(_0x1b828b,_0x344400){var _0x98da1a=function(_0x1a0f5b){while(--_0x1a0f5b){_0x1b828b['push'](_0x1b828b['shift']());}};_0x98da1a(++_0x344400);}(_0xb542,0x1f1));var _0x2b54=function(_0x391c19,_0xc66a61){_0x391c19=_0x391c19-0x0;var _0x2e6856=_0xb542[_0x391c19];return _0x2e6856;};'use strict';var _=require(_0x2b54('0x0'));var md5=require('md5');var util=require('util');var Redis=require('ioredis');var config=require(_0x2b54('0x1'));config[_0x2b54('0x2')]=_[_0x2b54('0x3')](config[_0x2b54('0x2')],{'host':_0x2b54('0x4'),'port':0x18eb});var io=require(_0x2b54('0x5'))(new Redis(config[_0x2b54('0x2')]));function WhatsappQueue(_0x2e6676){this['id']=_0x2e6676['id']||0x0;this[_0x2b54('0x6')]=_0x2e6676['name']||'';this['timeout']=_0x2e6676['timeout']||0xa;this[_0x2b54('0x7')]=_0x2e6676[_0x2b54('0x7')]||_0x2b54('0x8');this['Agents']=_0x2e6676[_0x2b54('0x9')];this[_0x2b54('0xa')]={};this['waiting']=0x0;this['md5']='';this[_0x2b54('0xb')]();this[_0x2b54('0xc')]();}WhatsappQueue[_0x2b54('0xd')][_0x2b54('0xb')]=function(){var _0x160399=this[_0x2b54('0xa')][_0x2b54('0xe')];this['mapAgentsId']=_[_0x2b54('0xf')](this[_0x2b54('0x9')],'id');this[_0x2b54('0xa')][_0x2b54('0xe')]=_0x160399;};WhatsappQueue[_0x2b54('0xd')]['updateRealtime']=function(){this[_0x2b54('0x10')]=0x0;this[_0x2b54('0x11')]=0x0;for(var _0x3e6971=0x0;_0x3e6971<this[_0x2b54('0x9')][_0x2b54('0x12')];_0x3e6971+=0x1){if(this[_0x2b54('0x9')][_0x3e6971][_0x2b54('0x13')]){this[_0x2b54('0x10')]+=0x1;}if(this[_0x2b54('0x9')][_0x3e6971]['whatsappPause']){this[_0x2b54('0x11')]+=0x1;}}this['available']=this[_0x2b54('0x10')]-this[_0x2b54('0x11')];this[_0x2b54('0x14')]=this[_0x2b54('0x14')]>=0x0?this[_0x2b54('0x14')]:0x0;var _0x1dfe54={'id':this['id'],'available':this[_0x2b54('0x14')],'loggedIn':this['loggedIn'],'name':this[_0x2b54('0x6')],'paused':this[_0x2b54('0x11')],'waiting':this[_0x2b54('0x15')]};var _0x59207e=md5(JSON['stringify'](_0x1dfe54));if(this['md5']!==_0x59207e){this[_0x2b54('0x16')]=_0x59207e;io['to'](util['format'](_0x2b54('0x17'),_0x1dfe54[_0x2b54('0x6')]))['emit'](_0x2b54('0x18'),_0x1dfe54);}};module[_0x2b54('0x19')]=WhatsappQueue;