Built motion from commit (unavailable).|2.5.3
[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 _0x05e6=['redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','md5','updateRouting','updateRealtime','map','_rr','prototype','loggedIn','paused','online','available','stringify','format','chat:queue:%s','chat_queue:save','lodash','ioredis'];(function(_0x3b46f8,_0x3353fd){var _0x435b1e=function(_0x3a7b2b){while(--_0x3a7b2b){_0x3b46f8['push'](_0x3b46f8['shift']());}};_0x435b1e(++_0x3353fd);}(_0x05e6,0x184));var _0x605e=function(_0x47e7cb,_0x4c1b8d){_0x47e7cb=_0x47e7cb-0x0;var _0x2a8874=_0x05e6[_0x47e7cb];return _0x2a8874;};'use strict';var _=require(_0x605e('0x0'));var md5=require('md5');var util=require('util');var Redis=require(_0x605e('0x1'));var config=require('../../../config/environment');config[_0x605e('0x2')]=_['defaults'](config[_0x605e('0x2')],{'host':_0x605e('0x3'),'port':0x18eb});var io=require(_0x605e('0x4'))(new Redis(config[_0x605e('0x2')]));function ChatQueue(_0x18f004){this['id']=_0x18f004['id']||0x0;this[_0x605e('0x5')]=_0x18f004[_0x605e('0x5')]||'';this[_0x605e('0x6')]=_0x18f004[_0x605e('0x6')]||0xa;this[_0x605e('0x7')]=_0x18f004[_0x605e('0x7')]||_0x605e('0x8');this['Agents']=_0x18f004[_0x605e('0x9')];this[_0x605e('0xa')]={};this[_0x605e('0xb')]=0x0;this[_0x605e('0xc')]='';this[_0x605e('0xd')]();this[_0x605e('0xe')]();}ChatQueue['prototype'][_0x605e('0xd')]=function(){var _0x5c583a=this[_0x605e('0xa')]['_rr'];this[_0x605e('0xa')]=_[_0x605e('0xf')](this['Agents'],'id');this[_0x605e('0xa')][_0x605e('0x10')]=_0x5c583a;};ChatQueue[_0x605e('0x11')]['updateRealtime']=function(){this[_0x605e('0x12')]=0x0;this[_0x605e('0x13')]=0x0;for(var _0x3366ea=0x0;_0x3366ea<this[_0x605e('0x9')]['length'];_0x3366ea+=0x1){if(this[_0x605e('0x9')][_0x3366ea][_0x605e('0x14')]){this['loggedIn']+=0x1;}if(this[_0x605e('0x9')][_0x3366ea]['chatPause']){this[_0x605e('0x13')]+=0x1;}}this['available']=this[_0x605e('0x12')]-this[_0x605e('0x13')];this['available']=this[_0x605e('0x15')]>=0x0?this[_0x605e('0x15')]:0x0;var _0x38e521={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this[_0x605e('0x5')],'paused':this['paused'],'waiting':this['waiting']};var _0x3914dc=md5(JSON[_0x605e('0x16')](_0x38e521));if(this['md5']!==_0x3914dc){this['md5']=_0x3914dc;io['to'](util[_0x605e('0x17')](_0x605e('0x18'),_0x38e521[_0x605e('0x5')]))['emit'](_0x605e('0x19'),_0x38e521);}};module['exports']=ChatQueue;