Built motion from commit 4ca75f1b.|2.6.28
[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 _0xabd3=['chat:queue:%s','emit','chat_queue:save','exports','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','map','loggedIn','paused','length','chatPause','available','format'];(function(_0x1f3bd4,_0x38029f){var _0x41d3d0=function(_0x339ed9){while(--_0x339ed9){_0x1f3bd4['push'](_0x1f3bd4['shift']());}};_0x41d3d0(++_0x38029f);}(_0xabd3,0x160));var _0x3abd=function(_0x454018,_0x46e33a){_0x454018=_0x454018-0x0;var _0x24697d=_0xabd3[_0x454018];return _0x24697d;};'use strict';var _=require('lodash');var md5=require(_0x3abd('0x0'));var util=require(_0x3abd('0x1'));var Redis=require(_0x3abd('0x2'));var config=require(_0x3abd('0x3'));config[_0x3abd('0x4')]=_[_0x3abd('0x5')](config['redis'],{'host':_0x3abd('0x6'),'port':0x18eb});var io=require(_0x3abd('0x7'))(new Redis(config[_0x3abd('0x4')]));function ChatQueue(_0x9af8e4){this['id']=_0x9af8e4['id']||0x0;this[_0x3abd('0x8')]=_0x9af8e4['name']||'';this[_0x3abd('0x9')]=_0x9af8e4['timeout']||0xa;this['strategy']=_0x9af8e4[_0x3abd('0xa')]||_0x3abd('0xb');this['Agents']=_0x9af8e4[_0x3abd('0xc')];this[_0x3abd('0xd')]={};this[_0x3abd('0xe')]=0x0;this['md5']='';this[_0x3abd('0xf')]();this[_0x3abd('0x10')]();}ChatQueue[_0x3abd('0x11')][_0x3abd('0xf')]=function(){var _0x19d5a1=this[_0x3abd('0xd')]['_rr'];this[_0x3abd('0xd')]=_[_0x3abd('0x12')](this[_0x3abd('0xc')],'id');this['mapAgentsId']['_rr']=_0x19d5a1;};ChatQueue[_0x3abd('0x11')][_0x3abd('0x10')]=function(){this[_0x3abd('0x13')]=0x0;this[_0x3abd('0x14')]=0x0;for(var _0xa290fd=0x0;_0xa290fd<this[_0x3abd('0xc')][_0x3abd('0x15')];_0xa290fd+=0x1){if(this[_0x3abd('0xc')][_0xa290fd]['online']){this['loggedIn']+=0x1;}if(this[_0x3abd('0xc')][_0xa290fd][_0x3abd('0x16')]){this[_0x3abd('0x14')]+=0x1;}}this[_0x3abd('0x17')]=this[_0x3abd('0x13')]-this['paused'];this[_0x3abd('0x17')]=this['available']>=0x0?this['available']:0x0;var _0x1a5487={'id':this['id'],'available':this[_0x3abd('0x17')],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this[_0x3abd('0x14')],'waiting':this['waiting']};var _0x299a72=md5(JSON['stringify'](_0x1a5487));if(this[_0x3abd('0x0')]!==_0x299a72){this[_0x3abd('0x0')]=_0x299a72;io['to'](util[_0x3abd('0x18')](_0x3abd('0x19'),_0x1a5487['name']))[_0x3abd('0x1a')](_0x3abd('0x1b'),_0x1a5487);}};module[_0x3abd('0x1c')]=ChatQueue;