Built motion from commit c116dc8b.|2.6.30
[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 _0x5928=['paused','length','online','chatPause','available','stringify','chat:queue:%s','emit','chat_queue:save','exports','md5','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','prototype','updateRouting','mapAgentsId','map','_rr','updateRealtime','loggedIn'];(function(_0x1ebce2,_0x10e903){var _0x4a330c=function(_0x4fd810){while(--_0x4fd810){_0x1ebce2['push'](_0x1ebce2['shift']());}};_0x4a330c(++_0x10e903);}(_0x5928,0x13e));var _0x8592=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x5928[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var md5=require(_0x8592('0x0'));var util=require('util');var Redis=require('ioredis');var config=require(_0x8592('0x1'));config[_0x8592('0x2')]=_[_0x8592('0x3')](config[_0x8592('0x2')],{'host':'localhost','port':0x18eb});var io=require(_0x8592('0x4'))(new Redis(config[_0x8592('0x2')]));function ChatQueue(_0x526a06){this['id']=_0x526a06['id']||0x0;this[_0x8592('0x5')]=_0x526a06[_0x8592('0x5')]||'';this[_0x8592('0x6')]=_0x526a06[_0x8592('0x6')]||0xa;this[_0x8592('0x7')]=_0x526a06[_0x8592('0x7')]||_0x8592('0x8');this[_0x8592('0x9')]=_0x526a06[_0x8592('0x9')];this['mapAgentsId']={};this[_0x8592('0xa')]=0x0;this[_0x8592('0x0')]='';this['updateRouting']();this['updateRealtime']();}ChatQueue[_0x8592('0xb')][_0x8592('0xc')]=function(){var _0x49ad16=this[_0x8592('0xd')]['_rr'];this[_0x8592('0xd')]=_[_0x8592('0xe')](this[_0x8592('0x9')],'id');this[_0x8592('0xd')][_0x8592('0xf')]=_0x49ad16;};ChatQueue[_0x8592('0xb')][_0x8592('0x10')]=function(){this[_0x8592('0x11')]=0x0;this[_0x8592('0x12')]=0x0;for(var _0x4509f9=0x0;_0x4509f9<this[_0x8592('0x9')][_0x8592('0x13')];_0x4509f9+=0x1){if(this['Agents'][_0x4509f9][_0x8592('0x14')]){this[_0x8592('0x11')]+=0x1;}if(this[_0x8592('0x9')][_0x4509f9][_0x8592('0x15')]){this[_0x8592('0x12')]+=0x1;}}this['available']=this[_0x8592('0x11')]-this[_0x8592('0x12')];this[_0x8592('0x16')]=this[_0x8592('0x16')]>=0x0?this['available']:0x0;var _0xa503d3={'id':this['id'],'available':this[_0x8592('0x16')],'loggedIn':this[_0x8592('0x11')],'name':this[_0x8592('0x5')],'paused':this[_0x8592('0x12')],'waiting':this[_0x8592('0xa')]};var _0x23346b=md5(JSON[_0x8592('0x17')](_0xa503d3));if(this['md5']!==_0x23346b){this[_0x8592('0x0')]=_0x23346b;io['to'](util['format'](_0x8592('0x18'),_0xa503d3[_0x8592('0x5')]))[_0x8592('0x19')](_0x8592('0x1a'),_0xa503d3);}};module[_0x8592('0x1b')]=ChatQueue;