Built motion from commit (unavailable).|2.5.21
[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 _0x90c0=['redis','defaults','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','md5','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length','online','whatsappPause','available','stringify','whatsapp:queue:%s','emit','whatsapp_queue:save','exports','lodash','util','ioredis','../../../config/environment'];(function(_0x53b93b,_0x1bfab1){var _0x485761=function(_0x41592e){while(--_0x41592e){_0x53b93b['push'](_0x53b93b['shift']());}};_0x485761(++_0x1bfab1);}(_0x90c0,0xec));var _0x090c=function(_0x32cf96,_0x7502d5){_0x32cf96=_0x32cf96-0x0;var _0x125cc1=_0x90c0[_0x32cf96];return _0x125cc1;};'use strict';var _=require(_0x090c('0x0'));var md5=require('md5');var util=require(_0x090c('0x1'));var Redis=require(_0x090c('0x2'));var config=require(_0x090c('0x3'));config[_0x090c('0x4')]=_[_0x090c('0x5')](config['redis'],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x090c('0x4')]));function WhatsappQueue(_0x3f1980){this['id']=_0x3f1980['id']||0x0;this['name']=_0x3f1980[_0x090c('0x6')]||'';this[_0x090c('0x7')]=_0x3f1980['timeout']||0xa;this[_0x090c('0x8')]=_0x3f1980[_0x090c('0x8')]||_0x090c('0x9');this[_0x090c('0xa')]=_0x3f1980[_0x090c('0xa')];this[_0x090c('0xb')]={};this[_0x090c('0xc')]=0x0;this[_0x090c('0xd')]='';this[_0x090c('0xe')]();this[_0x090c('0xf')]();}WhatsappQueue[_0x090c('0x10')][_0x090c('0xe')]=function(){var _0x39dc2c=this[_0x090c('0xb')][_0x090c('0x11')];this[_0x090c('0xb')]=_[_0x090c('0x12')](this['Agents'],'id');this[_0x090c('0xb')][_0x090c('0x11')]=_0x39dc2c;};WhatsappQueue['prototype'][_0x090c('0xf')]=function(){this[_0x090c('0x13')]=0x0;this[_0x090c('0x14')]=0x0;for(var _0x7f4133=0x0;_0x7f4133<this[_0x090c('0xa')][_0x090c('0x15')];_0x7f4133+=0x1){if(this['Agents'][_0x7f4133][_0x090c('0x16')]){this[_0x090c('0x13')]+=0x1;}if(this[_0x090c('0xa')][_0x7f4133][_0x090c('0x17')]){this[_0x090c('0x14')]+=0x1;}}this[_0x090c('0x18')]=this[_0x090c('0x13')]-this[_0x090c('0x14')];this['available']=this[_0x090c('0x18')]>=0x0?this[_0x090c('0x18')]:0x0;var _0xd685ad={'id':this['id'],'available':this[_0x090c('0x18')],'loggedIn':this['loggedIn'],'name':this[_0x090c('0x6')],'paused':this[_0x090c('0x14')],'waiting':this['waiting']};var _0x42804c=md5(JSON[_0x090c('0x19')](_0xd685ad));if(this[_0x090c('0xd')]!==_0x42804c){this[_0x090c('0xd')]=_0x42804c;io['to'](util['format'](_0x090c('0x1a'),_0xd685ad[_0x090c('0x6')]))[_0x090c('0x1b')](_0x090c('0x1c'),_0xd685ad);}};module[_0x090c('0x1d')]=WhatsappQueue;