1ea8777e06db4b504d224b540392f11037ee7d33
[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 _0x703f=['md5','updateRouting','_rr','map','loggedIn','length','chatPause','paused','available','stringify','format','chat:queue:%s','chat_queue:save','exports','lodash','util','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting'];(function(_0x47e4c2,_0x2544d2){var _0x15b451=function(_0x266867){while(--_0x266867){_0x47e4c2['push'](_0x47e4c2['shift']());}};_0x15b451(++_0x2544d2);}(_0x703f,0x196));var _0xf703=function(_0x1d4fbc,_0xc8ee19){_0x1d4fbc=_0x1d4fbc-0x0;var _0x2a9b95=_0x703f[_0x1d4fbc];return _0x2a9b95;};'use strict';var _=require(_0xf703('0x0'));var md5=require('md5');var util=require(_0xf703('0x1'));var Redis=require(_0xf703('0x2'));var config=require(_0xf703('0x3'));config[_0xf703('0x4')]=_[_0xf703('0x5')](config[_0xf703('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0xf703('0x6'))(new Redis(config[_0xf703('0x4')]));function ChatQueue(_0xadca2){this['id']=_0xadca2['id']||0x0;this[_0xf703('0x7')]=_0xadca2[_0xf703('0x7')]||'';this[_0xf703('0x8')]=_0xadca2[_0xf703('0x8')]||0xa;this[_0xf703('0x9')]=_0xadca2[_0xf703('0x9')]||_0xf703('0xa');this[_0xf703('0xb')]=_0xadca2[_0xf703('0xb')];this[_0xf703('0xc')]={};this[_0xf703('0xd')]=0x0;this[_0xf703('0xe')]='';this[_0xf703('0xf')]();this['updateRealtime']();}ChatQueue['prototype']['updateRouting']=function(){var _0x129a21=this[_0xf703('0xc')][_0xf703('0x10')];this[_0xf703('0xc')]=_[_0xf703('0x11')](this[_0xf703('0xb')],'id');this[_0xf703('0xc')][_0xf703('0x10')]=_0x129a21;};ChatQueue['prototype']['updateRealtime']=function(){this[_0xf703('0x12')]=0x0;this['paused']=0x0;for(var _0x27e5cc=0x0;_0x27e5cc<this[_0xf703('0xb')][_0xf703('0x13')];_0x27e5cc+=0x1){if(this['Agents'][_0x27e5cc]['online']){this[_0xf703('0x12')]+=0x1;}if(this['Agents'][_0x27e5cc][_0xf703('0x14')]){this[_0xf703('0x15')]+=0x1;}}this[_0xf703('0x16')]=this['loggedIn']-this[_0xf703('0x15')];this[_0xf703('0x16')]=this[_0xf703('0x16')]>=0x0?this['available']:0x0;var _0x2e0bbd={'id':this['id'],'available':this[_0xf703('0x16')],'loggedIn':this[_0xf703('0x12')],'name':this[_0xf703('0x7')],'paused':this['paused'],'waiting':this[_0xf703('0xd')]};var _0x33e6f8=md5(JSON[_0xf703('0x17')](_0x2e0bbd));if(this[_0xf703('0xe')]!==_0x33e6f8){this['md5']=_0x33e6f8;io['to'](util[_0xf703('0x18')](_0xf703('0x19'),_0x2e0bbd[_0xf703('0x7')]))['emit'](_0xf703('0x1a'),_0x2e0bbd);}};module[_0xf703('0x1b')]=ChatQueue;