Built motion from commit (unavailable).|2.6.0
[motion2.git] / server / services / routing / model / chatQueue.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 _0x2ca2=['lodash','util','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','md5','updateRealtime','prototype','updateRouting','mapAgentsId','_rr','map','loggedIn','length','chatPause','paused','available','stringify','emit'];(function(_0x2d2c51,_0xcefc73){var _0x410ec6=function(_0x16cb19){while(--_0x16cb19){_0x2d2c51['push'](_0x2d2c51['shift']());}};_0x410ec6(++_0xcefc73);}(_0x2ca2,0x87));var _0x22ca=function(_0x36c525,_0x51223c){_0x36c525=_0x36c525-0x0;var _0xd930fd=_0x2ca2[_0x36c525];return _0xd930fd;};'use strict';var _=require(_0x22ca('0x0'));var md5=require('md5');var util=require(_0x22ca('0x1'));var Redis=require(_0x22ca('0x2'));var config=require(_0x22ca('0x3'));config[_0x22ca('0x4')]=_['defaults'](config[_0x22ca('0x4')],{'host':_0x22ca('0x5'),'port':0x18eb});var io=require(_0x22ca('0x6'))(new Redis(config['redis']));function ChatQueue(_0x453a0e){this['id']=_0x453a0e['id']||0x0;this['name']=_0x453a0e[_0x22ca('0x7')]||'';this[_0x22ca('0x8')]=_0x453a0e['timeout']||0xa;this[_0x22ca('0x9')]=_0x453a0e[_0x22ca('0x9')]||_0x22ca('0xa');this[_0x22ca('0xb')]=_0x453a0e[_0x22ca('0xb')];this['mapAgentsId']={};this[_0x22ca('0xc')]=0x0;this[_0x22ca('0xd')]='';this['updateRouting']();this[_0x22ca('0xe')]();}ChatQueue[_0x22ca('0xf')][_0x22ca('0x10')]=function(){var _0x561606=this[_0x22ca('0x11')][_0x22ca('0x12')];this[_0x22ca('0x11')]=_[_0x22ca('0x13')](this[_0x22ca('0xb')],'id');this[_0x22ca('0x11')][_0x22ca('0x12')]=_0x561606;};ChatQueue[_0x22ca('0xf')]['updateRealtime']=function(){this[_0x22ca('0x14')]=0x0;this['paused']=0x0;for(var _0x4ccf72=0x0;_0x4ccf72<this['Agents'][_0x22ca('0x15')];_0x4ccf72+=0x1){if(this['Agents'][_0x4ccf72]['online']){this['loggedIn']+=0x1;}if(this[_0x22ca('0xb')][_0x4ccf72][_0x22ca('0x16')]){this[_0x22ca('0x17')]+=0x1;}}this[_0x22ca('0x18')]=this[_0x22ca('0x14')]-this[_0x22ca('0x17')];this[_0x22ca('0x18')]=this[_0x22ca('0x18')]>=0x0?this[_0x22ca('0x18')]:0x0;var _0x463dbd={'id':this['id'],'available':this[_0x22ca('0x18')],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this[_0x22ca('0x17')],'waiting':this[_0x22ca('0xc')]};var _0x167f44=md5(JSON[_0x22ca('0x19')](_0x463dbd));if(this[_0x22ca('0xd')]!==_0x167f44){this['md5']=_0x167f44;io['to'](util['format']('chat:queue:%s',_0x463dbd['name']))[_0x22ca('0x1a')]('chat_queue:save',_0x463dbd);}};module['exports']=ChatQueue;