Built motion from commit (unavailable).|2.5.11
[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 _0x0071=['loggedIn','length','whatsappPause','paused','available','stringify','whatsapp:queue:%s','md5','util','ioredis','../../../config/environment','defaults','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','prototype','_rr','updateRealtime'];(function(_0x1f3fa6,_0x3d1ae8){var _0x172879=function(_0x357b52){while(--_0x357b52){_0x1f3fa6['push'](_0x1f3fa6['shift']());}};_0x172879(++_0x3d1ae8);}(_0x0071,0x11a));var _0x1007=function(_0x250801,_0x1f3f7a){_0x250801=_0x250801-0x0;var _0x25648b=_0x0071[_0x250801];return _0x25648b;};'use strict';var _=require('lodash');var md5=require(_0x1007('0x0'));var util=require(_0x1007('0x1'));var Redis=require(_0x1007('0x2'));var config=require(_0x1007('0x3'));config['redis']=_[_0x1007('0x4')](config[_0x1007('0x5')],{'host':_0x1007('0x6'),'port':0x18eb});var io=require(_0x1007('0x7'))(new Redis(config[_0x1007('0x5')]));function WhatsappQueue(_0x5184e2){this['id']=_0x5184e2['id']||0x0;this[_0x1007('0x8')]=_0x5184e2[_0x1007('0x8')]||'';this[_0x1007('0x9')]=_0x5184e2[_0x1007('0x9')]||0xa;this[_0x1007('0xa')]=_0x5184e2[_0x1007('0xa')]||_0x1007('0xb');this[_0x1007('0xc')]=_0x5184e2['Agents'];this[_0x1007('0xd')]={};this['waiting']=0x0;this[_0x1007('0x0')]='';this[_0x1007('0xe')]();this['updateRealtime']();}WhatsappQueue[_0x1007('0xf')][_0x1007('0xe')]=function(){var _0x22b72b=this[_0x1007('0xd')]['_rr'];this[_0x1007('0xd')]=_['map'](this[_0x1007('0xc')],'id');this['mapAgentsId'][_0x1007('0x10')]=_0x22b72b;};WhatsappQueue['prototype'][_0x1007('0x11')]=function(){this[_0x1007('0x12')]=0x0;this['paused']=0x0;for(var _0x2cc1d3=0x0;_0x2cc1d3<this[_0x1007('0xc')][_0x1007('0x13')];_0x2cc1d3+=0x1){if(this[_0x1007('0xc')][_0x2cc1d3]['online']){this[_0x1007('0x12')]+=0x1;}if(this[_0x1007('0xc')][_0x2cc1d3][_0x1007('0x14')]){this['paused']+=0x1;}}this['available']=this[_0x1007('0x12')]-this[_0x1007('0x15')];this[_0x1007('0x16')]=this[_0x1007('0x16')]>=0x0?this[_0x1007('0x16')]:0x0;var _0x7c6f2e={'id':this['id'],'available':this[_0x1007('0x16')],'loggedIn':this[_0x1007('0x12')],'name':this[_0x1007('0x8')],'paused':this[_0x1007('0x15')],'waiting':this['waiting']};var _0x5a51a6=md5(JSON[_0x1007('0x17')](_0x7c6f2e));if(this['md5']!==_0x5a51a6){this[_0x1007('0x0')]=_0x5a51a6;io['to'](util['format'](_0x1007('0x18'),_0x7c6f2e[_0x1007('0x8')]))['emit']('whatsapp_queue:save',_0x7c6f2e);}};module['exports']=WhatsappQueue;