b161a1a18c861df4c3a64453f5c8f52dd35e00cc
[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 _0x423b=['prototype','updateRouting','_rr','online','chatPause','paused','available','loggedIn','stringify','format','chat:queue:%s','chat_queue:save','exports','lodash','util','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','md5','updateRealtime'];(function(_0xdecf39,_0x462cf1){var _0x5acc93=function(_0x22fe8e){while(--_0x22fe8e){_0xdecf39['push'](_0xdecf39['shift']());}};_0x5acc93(++_0x462cf1);}(_0x423b,0x195));var _0xb423=function(_0x1694f5,_0x49b7c3){_0x1694f5=_0x1694f5-0x0;var _0x5b4321=_0x423b[_0x1694f5];return _0x5b4321;};'use strict';var _=require(_0xb423('0x0'));var md5=require('md5');var util=require(_0xb423('0x1'));var Redis=require(_0xb423('0x2'));var config=require('../../../config/environment');config[_0xb423('0x3')]=_[_0xb423('0x4')](config['redis'],{'host':_0xb423('0x5'),'port':0x18eb});var io=require(_0xb423('0x6'))(new Redis(config['redis']));function ChatQueue(_0x39b8e8){this['id']=_0x39b8e8['id']||0x0;this['name']=_0x39b8e8[_0xb423('0x7')]||'';this[_0xb423('0x8')]=_0x39b8e8['timeout']||0xa;this[_0xb423('0x9')]=_0x39b8e8[_0xb423('0x9')]||'beepall';this[_0xb423('0xa')]=_0x39b8e8[_0xb423('0xa')];this[_0xb423('0xb')]={};this[_0xb423('0xc')]=0x0;this[_0xb423('0xd')]='';this['updateRouting']();this[_0xb423('0xe')]();}ChatQueue[_0xb423('0xf')][_0xb423('0x10')]=function(){var _0x205c6f=this[_0xb423('0xb')][_0xb423('0x11')];this[_0xb423('0xb')]=_['map'](this['Agents'],'id');this[_0xb423('0xb')][_0xb423('0x11')]=_0x205c6f;};ChatQueue[_0xb423('0xf')][_0xb423('0xe')]=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x5c0474=0x0;_0x5c0474<this[_0xb423('0xa')]['length'];_0x5c0474+=0x1){if(this[_0xb423('0xa')][_0x5c0474][_0xb423('0x12')]){this['loggedIn']+=0x1;}if(this[_0xb423('0xa')][_0x5c0474][_0xb423('0x13')]){this[_0xb423('0x14')]+=0x1;}}this[_0xb423('0x15')]=this['loggedIn']-this['paused'];this[_0xb423('0x15')]=this['available']>=0x0?this['available']:0x0;var _0x50a4af={'id':this['id'],'available':this[_0xb423('0x15')],'loggedIn':this[_0xb423('0x16')],'name':this[_0xb423('0x7')],'paused':this['paused'],'waiting':this[_0xb423('0xc')]};var _0x3f2d66=md5(JSON[_0xb423('0x17')](_0x50a4af));if(this['md5']!==_0x3f2d66){this[_0xb423('0xd')]=_0x3f2d66;io['to'](util[_0xb423('0x18')](_0xb423('0x19'),_0x50a4af['name']))['emit'](_0xb423('0x1a'),_0x50a4af);}};module[_0xb423('0x1b')]=ChatQueue;