Built motion from commit (unavailable).|2.5.11
[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 _0x1ee0=['Agents','waiting','updateRealtime','prototype','mapAgentsId','_rr','map','loggedIn','paused','length','online','whatsappPause','available','stringify','format','whatsapp:queue:%s','emit','whatsapp_queue:save','exports','lodash','md5','util','ioredis','defaults','redis','name','timeout','strategy','beepall'];(function(_0x1924dd,_0x427dfe){var _0x3ffad8=function(_0x20bfe9){while(--_0x20bfe9){_0x1924dd['push'](_0x1924dd['shift']());}};_0x3ffad8(++_0x427dfe);}(_0x1ee0,0xfb));var _0x01ee=function(_0x44ae1c,_0x45b288){_0x44ae1c=_0x44ae1c-0x0;var _0x5db685=_0x1ee0[_0x44ae1c];return _0x5db685;};'use strict';var _=require(_0x01ee('0x0'));var md5=require(_0x01ee('0x1'));var util=require(_0x01ee('0x2'));var Redis=require(_0x01ee('0x3'));var config=require('../../../config/environment');config['redis']=_[_0x01ee('0x4')](config['redis'],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x01ee('0x5')]));function WhatsappQueue(_0x49e49e){this['id']=_0x49e49e['id']||0x0;this[_0x01ee('0x6')]=_0x49e49e['name']||'';this[_0x01ee('0x7')]=_0x49e49e[_0x01ee('0x7')]||0xa;this[_0x01ee('0x8')]=_0x49e49e[_0x01ee('0x8')]||_0x01ee('0x9');this[_0x01ee('0xa')]=_0x49e49e[_0x01ee('0xa')];this['mapAgentsId']={};this[_0x01ee('0xb')]=0x0;this[_0x01ee('0x1')]='';this['updateRouting']();this[_0x01ee('0xc')]();}WhatsappQueue[_0x01ee('0xd')]['updateRouting']=function(){var _0xe50c95=this[_0x01ee('0xe')][_0x01ee('0xf')];this[_0x01ee('0xe')]=_[_0x01ee('0x10')](this[_0x01ee('0xa')],'id');this[_0x01ee('0xe')][_0x01ee('0xf')]=_0xe50c95;};WhatsappQueue[_0x01ee('0xd')][_0x01ee('0xc')]=function(){this[_0x01ee('0x11')]=0x0;this[_0x01ee('0x12')]=0x0;for(var _0x1a21f3=0x0;_0x1a21f3<this[_0x01ee('0xa')][_0x01ee('0x13')];_0x1a21f3+=0x1){if(this['Agents'][_0x1a21f3][_0x01ee('0x14')]){this[_0x01ee('0x11')]+=0x1;}if(this[_0x01ee('0xa')][_0x1a21f3][_0x01ee('0x15')]){this[_0x01ee('0x12')]+=0x1;}}this[_0x01ee('0x16')]=this[_0x01ee('0x11')]-this['paused'];this['available']=this['available']>=0x0?this[_0x01ee('0x16')]:0x0;var _0x34497d={'id':this['id'],'available':this[_0x01ee('0x16')],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this[_0x01ee('0x12')],'waiting':this['waiting']};var _0xf9361e=md5(JSON[_0x01ee('0x17')](_0x34497d));if(this[_0x01ee('0x1')]!==_0xf9361e){this['md5']=_0xf9361e;io['to'](util[_0x01ee('0x18')](_0x01ee('0x19'),_0x34497d['name']))[_0x01ee('0x1a')](_0x01ee('0x1b'),_0x34497d);}};module[_0x01ee('0x1c')]=WhatsappQueue;