8b386adc2c49a4ce48dc827fc93d48778960f373
[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 _0x299b=['map','paused','online','loggedIn','whatsappPause','available','stringify','format','emit','lodash','md5','util','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRealtime','prototype','updateRouting'];(function(_0x4565bf,_0x5ad9d6){var _0x5610ba=function(_0x170988){while(--_0x170988){_0x4565bf['push'](_0x4565bf['shift']());}};_0x5610ba(++_0x5ad9d6);}(_0x299b,0x1c3));var _0xb299=function(_0x58ae8a,_0x3c619e){_0x58ae8a=_0x58ae8a-0x0;var _0x2f0b6b=_0x299b[_0x58ae8a];return _0x2f0b6b;};'use strict';var _=require(_0xb299('0x0'));var md5=require(_0xb299('0x1'));var util=require(_0xb299('0x2'));var Redis=require(_0xb299('0x3'));var config=require('../../../config/environment');config[_0xb299('0x4')]=_[_0xb299('0x5')](config[_0xb299('0x4')],{'host':_0xb299('0x6'),'port':0x18eb});var io=require(_0xb299('0x7'))(new Redis(config['redis']));function WhatsappQueue(_0x526656){this['id']=_0x526656['id']||0x0;this[_0xb299('0x8')]=_0x526656['name']||'';this[_0xb299('0x9')]=_0x526656[_0xb299('0x9')]||0xa;this['strategy']=_0x526656[_0xb299('0xa')]||_0xb299('0xb');this['Agents']=_0x526656[_0xb299('0xc')];this[_0xb299('0xd')]={};this['waiting']=0x0;this[_0xb299('0x1')]='';this['updateRouting']();this[_0xb299('0xe')]();}WhatsappQueue[_0xb299('0xf')][_0xb299('0x10')]=function(){var _0x244a30=this['mapAgentsId']['_rr'];this[_0xb299('0xd')]=_[_0xb299('0x11')](this[_0xb299('0xc')],'id');this[_0xb299('0xd')]['_rr']=_0x244a30;};WhatsappQueue[_0xb299('0xf')][_0xb299('0xe')]=function(){this['loggedIn']=0x0;this[_0xb299('0x12')]=0x0;for(var _0x43747a=0x0;_0x43747a<this[_0xb299('0xc')]['length'];_0x43747a+=0x1){if(this[_0xb299('0xc')][_0x43747a][_0xb299('0x13')]){this[_0xb299('0x14')]+=0x1;}if(this[_0xb299('0xc')][_0x43747a][_0xb299('0x15')]){this[_0xb299('0x12')]+=0x1;}}this[_0xb299('0x16')]=this['loggedIn']-this[_0xb299('0x12')];this[_0xb299('0x16')]=this[_0xb299('0x16')]>=0x0?this['available']:0x0;var _0x439a20={'id':this['id'],'available':this['available'],'loggedIn':this[_0xb299('0x14')],'name':this[_0xb299('0x8')],'paused':this[_0xb299('0x12')],'waiting':this['waiting']};var _0x14d8a8=md5(JSON[_0xb299('0x17')](_0x439a20));if(this['md5']!==_0x14d8a8){this['md5']=_0x14d8a8;io['to'](util[_0xb299('0x18')]('whatsapp:queue:%s',_0x439a20[_0xb299('0x8')]))[_0xb299('0x19')]('whatsapp_queue:save',_0x439a20);}};module['exports']=WhatsappQueue;