Built motion from commit bab6f49e.|2.6.17
[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 _0x9691=['whatsappPause','paused','available','loggedIn','stringify','format','emit','exports','lodash','util','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','md5','updateRealtime','prototype','updateRouting','_rr','map','length','online'];(function(_0x109bdb,_0xc5ba4){var _0x34a9f1=function(_0x56469d){while(--_0x56469d){_0x109bdb['push'](_0x109bdb['shift']());}};_0x34a9f1(++_0xc5ba4);}(_0x9691,0x19e));var _0x1969=function(_0x49dc8b,_0x28ff52){_0x49dc8b=_0x49dc8b-0x0;var _0x6cef66=_0x9691[_0x49dc8b];return _0x6cef66;};'use strict';var _=require(_0x1969('0x0'));var md5=require('md5');var util=require(_0x1969('0x1'));var Redis=require(_0x1969('0x2'));var config=require(_0x1969('0x3'));config[_0x1969('0x4')]=_['defaults'](config[_0x1969('0x4')],{'host':_0x1969('0x5'),'port':0x18eb});var io=require(_0x1969('0x6'))(new Redis(config['redis']));function WhatsappQueue(_0x4a9d7e){this['id']=_0x4a9d7e['id']||0x0;this['name']=_0x4a9d7e[_0x1969('0x7')]||'';this['timeout']=_0x4a9d7e[_0x1969('0x8')]||0xa;this[_0x1969('0x9')]=_0x4a9d7e[_0x1969('0x9')]||_0x1969('0xa');this[_0x1969('0xb')]=_0x4a9d7e[_0x1969('0xb')];this[_0x1969('0xc')]={};this['waiting']=0x0;this[_0x1969('0xd')]='';this['updateRouting']();this[_0x1969('0xe')]();}WhatsappQueue[_0x1969('0xf')][_0x1969('0x10')]=function(){var _0x3dbe7c=this[_0x1969('0xc')][_0x1969('0x11')];this[_0x1969('0xc')]=_[_0x1969('0x12')](this[_0x1969('0xb')],'id');this['mapAgentsId']['_rr']=_0x3dbe7c;};WhatsappQueue[_0x1969('0xf')][_0x1969('0xe')]=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x3be60e=0x0;_0x3be60e<this[_0x1969('0xb')][_0x1969('0x13')];_0x3be60e+=0x1){if(this[_0x1969('0xb')][_0x3be60e][_0x1969('0x14')]){this['loggedIn']+=0x1;}if(this[_0x1969('0xb')][_0x3be60e][_0x1969('0x15')]){this[_0x1969('0x16')]+=0x1;}}this[_0x1969('0x17')]=this[_0x1969('0x18')]-this[_0x1969('0x16')];this[_0x1969('0x17')]=this[_0x1969('0x17')]>=0x0?this[_0x1969('0x17')]:0x0;var _0xd13854={'id':this['id'],'available':this['available'],'loggedIn':this[_0x1969('0x18')],'name':this[_0x1969('0x7')],'paused':this[_0x1969('0x16')],'waiting':this['waiting']};var _0x7e88c4=md5(JSON[_0x1969('0x19')](_0xd13854));if(this['md5']!==_0x7e88c4){this['md5']=_0x7e88c4;io['to'](util[_0x1969('0x1a')]('whatsapp:queue:%s',_0xd13854[_0x1969('0x7')]))[_0x1969('0x1b')]('whatsapp_queue:save',_0xd13854);}};module[_0x1969('0x1c')]=WhatsappQueue;