Built motion from commit (unavailable).|2.5.1
[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 _0x4286=['md5','util','../../../config/environment','defaults','redis','localhost','socket.io-emitter','name','strategy','beepall','Agents','mapAgentsId','waiting','updateRealtime','prototype','updateRouting','_rr','map','loggedIn','length','online','whatsappPause','available','paused','stringify','format','whatsapp:queue:%s','whatsapp_queue:save','exports','lodash'];(function(_0x17a4aa,_0x5c72c7){var _0x485504=function(_0x3edc4f){while(--_0x3edc4f){_0x17a4aa['push'](_0x17a4aa['shift']());}};_0x485504(++_0x5c72c7);}(_0x4286,0x149));var _0x6428=function(_0x4d2ac8,_0x5597bc){_0x4d2ac8=_0x4d2ac8-0x0;var _0x555ffa=_0x4286[_0x4d2ac8];return _0x555ffa;};'use strict';var _=require(_0x6428('0x0'));var md5=require(_0x6428('0x1'));var util=require(_0x6428('0x2'));var Redis=require('ioredis');var config=require(_0x6428('0x3'));config['redis']=_[_0x6428('0x4')](config[_0x6428('0x5')],{'host':_0x6428('0x6'),'port':0x18eb});var io=require(_0x6428('0x7'))(new Redis(config[_0x6428('0x5')]));function WhatsappQueue(_0xebba1a){this['id']=_0xebba1a['id']||0x0;this[_0x6428('0x8')]=_0xebba1a[_0x6428('0x8')]||'';this['timeout']=_0xebba1a['timeout']||0xa;this[_0x6428('0x9')]=_0xebba1a['strategy']||_0x6428('0xa');this['Agents']=_0xebba1a[_0x6428('0xb')];this[_0x6428('0xc')]={};this[_0x6428('0xd')]=0x0;this[_0x6428('0x1')]='';this['updateRouting']();this[_0x6428('0xe')]();}WhatsappQueue[_0x6428('0xf')][_0x6428('0x10')]=function(){var _0x528e44=this['mapAgentsId'][_0x6428('0x11')];this[_0x6428('0xc')]=_[_0x6428('0x12')](this[_0x6428('0xb')],'id');this[_0x6428('0xc')][_0x6428('0x11')]=_0x528e44;};WhatsappQueue[_0x6428('0xf')][_0x6428('0xe')]=function(){this[_0x6428('0x13')]=0x0;this['paused']=0x0;for(var _0x3d86d3=0x0;_0x3d86d3<this[_0x6428('0xb')][_0x6428('0x14')];_0x3d86d3+=0x1){if(this[_0x6428('0xb')][_0x3d86d3][_0x6428('0x15')]){this[_0x6428('0x13')]+=0x1;}if(this[_0x6428('0xb')][_0x3d86d3][_0x6428('0x16')]){this['paused']+=0x1;}}this[_0x6428('0x17')]=this['loggedIn']-this[_0x6428('0x18')];this['available']=this[_0x6428('0x17')]>=0x0?this['available']:0x0;var _0x50308a={'id':this['id'],'available':this[_0x6428('0x17')],'loggedIn':this['loggedIn'],'name':this[_0x6428('0x8')],'paused':this[_0x6428('0x18')],'waiting':this[_0x6428('0xd')]};var _0x228e21=md5(JSON[_0x6428('0x19')](_0x50308a));if(this[_0x6428('0x1')]!==_0x228e21){this[_0x6428('0x1')]=_0x228e21;io['to'](util[_0x6428('0x1a')](_0x6428('0x1b'),_0x50308a['name']))['emit'](_0x6428('0x1c'),_0x50308a);}};module[_0x6428('0x1d')]=WhatsappQueue;