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 _0xb719=['waiting','updateRealtime','prototype','_rr','mapAgentsId','map','loggedIn','paused','length','online','whatsappPause','available','format','whatsapp:queue:%s','emit','whatsapp_queue:save','exports','lodash','md5','defaults','redis','localhost','name','timeout','strategy','beepall','Agents'];(function(_0x7f2429,_0x3004be){var _0x2a02d8=function(_0x57dbee){while(--_0x57dbee){_0x7f2429['push'](_0x7f2429['shift']());}};_0x2a02d8(++_0x3004be);}(_0xb719,0x13a));var _0x9b71=function(_0x465aa9,_0x1bf1c8){_0x465aa9=_0x465aa9-0x0;var _0x4104e4=_0xb719[_0x465aa9];return _0x4104e4;};'use strict';var _=require(_0x9b71('0x0'));var md5=require(_0x9b71('0x1'));var util=require('util');var Redis=require('ioredis');var config=require('../../../config/environment');config['redis']=_[_0x9b71('0x2')](config[_0x9b71('0x3')],{'host':_0x9b71('0x4'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x9b71('0x3')]));function WhatsappQueue(_0x1d02f7){this['id']=_0x1d02f7['id']||0x0;this['name']=_0x1d02f7[_0x9b71('0x5')]||'';this[_0x9b71('0x6')]=_0x1d02f7[_0x9b71('0x6')]||0xa;this[_0x9b71('0x7')]=_0x1d02f7[_0x9b71('0x7')]||_0x9b71('0x8');this['Agents']=_0x1d02f7[_0x9b71('0x9')];this['mapAgentsId']={};this[_0x9b71('0xa')]=0x0;this[_0x9b71('0x1')]='';this['updateRouting']();this[_0x9b71('0xb')]();}WhatsappQueue[_0x9b71('0xc')]['updateRouting']=function(){var _0x3aee6f=this['mapAgentsId'][_0x9b71('0xd')];this[_0x9b71('0xe')]=_[_0x9b71('0xf')](this['Agents'],'id');this[_0x9b71('0xe')][_0x9b71('0xd')]=_0x3aee6f;};WhatsappQueue['prototype']['updateRealtime']=function(){this[_0x9b71('0x10')]=0x0;this[_0x9b71('0x11')]=0x0;for(var _0x2ccc22=0x0;_0x2ccc22<this['Agents'][_0x9b71('0x12')];_0x2ccc22+=0x1){if(this['Agents'][_0x2ccc22][_0x9b71('0x13')]){this[_0x9b71('0x10')]+=0x1;}if(this[_0x9b71('0x9')][_0x2ccc22][_0x9b71('0x14')]){this['paused']+=0x1;}}this[_0x9b71('0x15')]=this['loggedIn']-this[_0x9b71('0x11')];this[_0x9b71('0x15')]=this[_0x9b71('0x15')]>=0x0?this[_0x9b71('0x15')]:0x0;var _0x304eb4={'id':this['id'],'available':this[_0x9b71('0x15')],'loggedIn':this[_0x9b71('0x10')],'name':this['name'],'paused':this[_0x9b71('0x11')],'waiting':this[_0x9b71('0xa')]};var _0x486b7d=md5(JSON['stringify'](_0x304eb4));if(this[_0x9b71('0x1')]!==_0x486b7d){this[_0x9b71('0x1')]=_0x486b7d;io['to'](util[_0x9b71('0x16')](_0x9b71('0x17'),_0x304eb4['name']))[_0x9b71('0x18')](_0x9b71('0x19'),_0x304eb4);}};module[_0x9b71('0x1a')]=WhatsappQueue;