Built motion from commit 26d08302.|2.6.31
[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 _0x626f=['updateRouting','updateRealtime','prototype','_rr','map','paused','length','loggedIn','whatsappPause','available','stringify','whatsapp:queue:%s','emit','whatsapp_queue:save','exports','md5','ioredis','../../../config/environment','defaults','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting'];(function(_0x78c5b7,_0x48efd1){var _0xa3221b=function(_0x288f3b){while(--_0x288f3b){_0x78c5b7['push'](_0x78c5b7['shift']());}};_0xa3221b(++_0x48efd1);}(_0x626f,0xf7));var _0xf626=function(_0xd8bb2e,_0x5a20a5){_0xd8bb2e=_0xd8bb2e-0x0;var _0x2ec658=_0x626f[_0xd8bb2e];return _0x2ec658;};'use strict';var _=require('lodash');var md5=require(_0xf626('0x0'));var util=require('util');var Redis=require(_0xf626('0x1'));var config=require(_0xf626('0x2'));config['redis']=_[_0xf626('0x3')](config[_0xf626('0x4')],{'host':_0xf626('0x5'),'port':0x18eb});var io=require(_0xf626('0x6'))(new Redis(config[_0xf626('0x4')]));function WhatsappQueue(_0x19ad37){this['id']=_0x19ad37['id']||0x0;this[_0xf626('0x7')]=_0x19ad37[_0xf626('0x7')]||'';this[_0xf626('0x8')]=_0x19ad37[_0xf626('0x8')]||0xa;this['strategy']=_0x19ad37[_0xf626('0x9')]||_0xf626('0xa');this[_0xf626('0xb')]=_0x19ad37[_0xf626('0xb')];this[_0xf626('0xc')]={};this[_0xf626('0xd')]=0x0;this[_0xf626('0x0')]='';this[_0xf626('0xe')]();this[_0xf626('0xf')]();}WhatsappQueue[_0xf626('0x10')][_0xf626('0xe')]=function(){var _0x45063c=this[_0xf626('0xc')][_0xf626('0x11')];this[_0xf626('0xc')]=_[_0xf626('0x12')](this['Agents'],'id');this['mapAgentsId'][_0xf626('0x11')]=_0x45063c;};WhatsappQueue['prototype'][_0xf626('0xf')]=function(){this['loggedIn']=0x0;this[_0xf626('0x13')]=0x0;for(var _0x13c8aa=0x0;_0x13c8aa<this['Agents'][_0xf626('0x14')];_0x13c8aa+=0x1){if(this['Agents'][_0x13c8aa]['online']){this[_0xf626('0x15')]+=0x1;}if(this[_0xf626('0xb')][_0x13c8aa][_0xf626('0x16')]){this['paused']+=0x1;}}this[_0xf626('0x17')]=this[_0xf626('0x15')]-this[_0xf626('0x13')];this['available']=this[_0xf626('0x17')]>=0x0?this[_0xf626('0x17')]:0x0;var _0x1e7edb={'id':this['id'],'available':this[_0xf626('0x17')],'loggedIn':this[_0xf626('0x15')],'name':this[_0xf626('0x7')],'paused':this[_0xf626('0x13')],'waiting':this[_0xf626('0xd')]};var _0x203740=md5(JSON[_0xf626('0x18')](_0x1e7edb));if(this[_0xf626('0x0')]!==_0x203740){this[_0xf626('0x0')]=_0x203740;io['to'](util['format'](_0xf626('0x19'),_0x1e7edb[_0xf626('0x7')]))[_0xf626('0x1a')](_0xf626('0x1b'),_0x1e7edb);}};module[_0xf626('0x1c')]=WhatsappQueue;