Built motion from commit (unavailable).|2.5.3
[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 _0x1488=['exports','lodash','util','ioredis','../../../config/environment','redis','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','md5','updateRouting','updateRealtime','prototype','map','paused','length','loggedIn','stringify','format','whatsapp:queue:%s','emit','whatsapp_queue:save'];(function(_0x34677a,_0xc29ca8){var _0x3bb373=function(_0x503256){while(--_0x503256){_0x34677a['push'](_0x34677a['shift']());}};_0x3bb373(++_0xc29ca8);}(_0x1488,0x88));var _0x8148=function(_0x2cc0b3,_0x120bf1){_0x2cc0b3=_0x2cc0b3-0x0;var _0x1667ef=_0x1488[_0x2cc0b3];return _0x1667ef;};'use strict';var _=require(_0x8148('0x0'));var md5=require('md5');var util=require(_0x8148('0x1'));var Redis=require(_0x8148('0x2'));var config=require(_0x8148('0x3'));config['redis']=_['defaults'](config[_0x8148('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x8148('0x5'))(new Redis(config[_0x8148('0x4')]));function WhatsappQueue(_0x11027){this['id']=_0x11027['id']||0x0;this[_0x8148('0x6')]=_0x11027[_0x8148('0x6')]||'';this[_0x8148('0x7')]=_0x11027[_0x8148('0x7')]||0xa;this[_0x8148('0x8')]=_0x11027['strategy']||_0x8148('0x9');this[_0x8148('0xa')]=_0x11027[_0x8148('0xa')];this[_0x8148('0xb')]={};this[_0x8148('0xc')]=0x0;this[_0x8148('0xd')]='';this[_0x8148('0xe')]();this[_0x8148('0xf')]();}WhatsappQueue[_0x8148('0x10')][_0x8148('0xe')]=function(){var _0x4a785c=this[_0x8148('0xb')]['_rr'];this[_0x8148('0xb')]=_[_0x8148('0x11')](this[_0x8148('0xa')],'id');this['mapAgentsId']['_rr']=_0x4a785c;};WhatsappQueue[_0x8148('0x10')][_0x8148('0xf')]=function(){this['loggedIn']=0x0;this[_0x8148('0x12')]=0x0;for(var _0x15478c=0x0;_0x15478c<this[_0x8148('0xa')][_0x8148('0x13')];_0x15478c+=0x1){if(this[_0x8148('0xa')][_0x15478c]['online']){this[_0x8148('0x14')]+=0x1;}if(this['Agents'][_0x15478c]['whatsappPause']){this[_0x8148('0x12')]+=0x1;}}this['available']=this['loggedIn']-this[_0x8148('0x12')];this['available']=this['available']>=0x0?this['available']:0x0;var _0xc4092a={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this[_0x8148('0x6')],'paused':this['paused'],'waiting':this[_0x8148('0xc')]};var _0x4a5256=md5(JSON[_0x8148('0x15')](_0xc4092a));if(this[_0x8148('0xd')]!==_0x4a5256){this[_0x8148('0xd')]=_0x4a5256;io['to'](util[_0x8148('0x16')](_0x8148('0x17'),_0xc4092a[_0x8148('0x6')]))[_0x8148('0x18')](_0x8148('0x19'),_0xc4092a);}};module[_0x8148('0x1a')]=WhatsappQueue;