Built motion from commit ce03bc3d.|2.5.39
[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 _0x3fb9=['online','whatsappPause','available','format','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','updateRouting','updateRealtime','prototype','mapAgentsId','_rr','loggedIn','paused','length'];(function(_0x80f51a,_0x32e95e){var _0x327148=function(_0x16f788){while(--_0x16f788){_0x80f51a['push'](_0x80f51a['shift']());}};_0x327148(++_0x32e95e);}(_0x3fb9,0x18d));var _0x93fb=function(_0x3dfa64,_0x50c771){_0x3dfa64=_0x3dfa64-0x0;var _0x485974=_0x3fb9[_0x3dfa64];return _0x485974;};'use strict';var _=require(_0x93fb('0x0'));var md5=require(_0x93fb('0x1'));var util=require(_0x93fb('0x2'));var Redis=require(_0x93fb('0x3'));var config=require(_0x93fb('0x4'));config[_0x93fb('0x5')]=_[_0x93fb('0x6')](config[_0x93fb('0x5')],{'host':_0x93fb('0x7'),'port':0x18eb});var io=require(_0x93fb('0x8'))(new Redis(config[_0x93fb('0x5')]));function WhatsappQueue(_0x33151b){this['id']=_0x33151b['id']||0x0;this[_0x93fb('0x9')]=_0x33151b[_0x93fb('0x9')]||'';this['timeout']=_0x33151b[_0x93fb('0xa')]||0xa;this[_0x93fb('0xb')]=_0x33151b[_0x93fb('0xb')]||_0x93fb('0xc');this['Agents']=_0x33151b[_0x93fb('0xd')];this['mapAgentsId']={};this[_0x93fb('0xe')]=0x0;this['md5']='';this[_0x93fb('0xf')]();this[_0x93fb('0x10')]();}WhatsappQueue[_0x93fb('0x11')][_0x93fb('0xf')]=function(){var _0x5e6fbf=this[_0x93fb('0x12')]['_rr'];this[_0x93fb('0x12')]=_['map'](this[_0x93fb('0xd')],'id');this[_0x93fb('0x12')][_0x93fb('0x13')]=_0x5e6fbf;};WhatsappQueue[_0x93fb('0x11')][_0x93fb('0x10')]=function(){this[_0x93fb('0x14')]=0x0;this[_0x93fb('0x15')]=0x0;for(var _0x36a22b=0x0;_0x36a22b<this[_0x93fb('0xd')][_0x93fb('0x16')];_0x36a22b+=0x1){if(this['Agents'][_0x36a22b][_0x93fb('0x17')]){this['loggedIn']+=0x1;}if(this[_0x93fb('0xd')][_0x36a22b][_0x93fb('0x18')]){this['paused']+=0x1;}}this['available']=this[_0x93fb('0x14')]-this['paused'];this[_0x93fb('0x19')]=this[_0x93fb('0x19')]>=0x0?this[_0x93fb('0x19')]:0x0;var _0x2a8561={'id':this['id'],'available':this[_0x93fb('0x19')],'loggedIn':this[_0x93fb('0x14')],'name':this['name'],'paused':this[_0x93fb('0x15')],'waiting':this['waiting']};var _0x5269f7=md5(JSON['stringify'](_0x2a8561));if(this[_0x93fb('0x1')]!==_0x5269f7){this[_0x93fb('0x1')]=_0x5269f7;io['to'](util[_0x93fb('0x1a')]('whatsapp:queue:%s',_0x2a8561['name']))['emit']('whatsapp_queue:save',_0x2a8561);}};module[_0x93fb('0x1b')]=WhatsappQueue;