aab189e9d5d18a18705d7a3c5fb09417fad6fe9b
[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 _0x5de8=['name','waiting','whatsapp:queue:%s','emit','whatsapp_queue:save','exports','lodash','md5','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','prototype','map','_rr','updateRealtime','loggedIn','paused','length','online','whatsappPause','available'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x5de8,0x114));var _0x85de=function(_0x41089f,_0x5d1190){_0x41089f=_0x41089f-0x0;var _0x207cbd=_0x5de8[_0x41089f];return _0x207cbd;};'use strict';var _=require(_0x85de('0x0'));var md5=require(_0x85de('0x1'));var util=require('util');var Redis=require(_0x85de('0x2'));var config=require(_0x85de('0x3'));config[_0x85de('0x4')]=_[_0x85de('0x5')](config[_0x85de('0x4')],{'host':_0x85de('0x6'),'port':0x18eb});var io=require(_0x85de('0x7'))(new Redis(config[_0x85de('0x4')]));function WhatsappQueue(_0x224575){this['id']=_0x224575['id']||0x0;this['name']=_0x224575['name']||'';this['timeout']=_0x224575[_0x85de('0x8')]||0xa;this[_0x85de('0x9')]=_0x224575[_0x85de('0x9')]||_0x85de('0xa');this[_0x85de('0xb')]=_0x224575['Agents'];this[_0x85de('0xc')]={};this['waiting']=0x0;this['md5']='';this[_0x85de('0xd')]();this['updateRealtime']();}WhatsappQueue[_0x85de('0xe')]['updateRouting']=function(){var _0xe2d22a=this[_0x85de('0xc')]['_rr'];this['mapAgentsId']=_[_0x85de('0xf')](this[_0x85de('0xb')],'id');this[_0x85de('0xc')][_0x85de('0x10')]=_0xe2d22a;};WhatsappQueue[_0x85de('0xe')][_0x85de('0x11')]=function(){this[_0x85de('0x12')]=0x0;this[_0x85de('0x13')]=0x0;for(var _0xc52a69=0x0;_0xc52a69<this[_0x85de('0xb')][_0x85de('0x14')];_0xc52a69+=0x1){if(this[_0x85de('0xb')][_0xc52a69][_0x85de('0x15')]){this['loggedIn']+=0x1;}if(this['Agents'][_0xc52a69][_0x85de('0x16')]){this[_0x85de('0x13')]+=0x1;}}this[_0x85de('0x17')]=this[_0x85de('0x12')]-this[_0x85de('0x13')];this[_0x85de('0x17')]=this['available']>=0x0?this[_0x85de('0x17')]:0x0;var _0x2b3956={'id':this['id'],'available':this[_0x85de('0x17')],'loggedIn':this[_0x85de('0x12')],'name':this[_0x85de('0x18')],'paused':this[_0x85de('0x13')],'waiting':this[_0x85de('0x19')]};var _0x1856f6=md5(JSON['stringify'](_0x2b3956));if(this[_0x85de('0x1')]!==_0x1856f6){this[_0x85de('0x1')]=_0x1856f6;io['to'](util['format'](_0x85de('0x1a'),_0x2b3956['name']))[_0x85de('0x1b')](_0x85de('0x1c'),_0x2b3956);}};module[_0x85de('0x1d')]=WhatsappQueue;