Built motion from commit 7158bc59.|2.5.42
[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 _0x113a=['paused','chat:queue:%s','chat_queue:save','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','beepall','Agents','waiting','updateRealtime','prototype','mapAgentsId','_rr','length','chatPause','available','loggedIn'];(function(_0x2b2ef0,_0x3decc9){var _0x27125b=function(_0x19b9b2){while(--_0x19b9b2){_0x2b2ef0['push'](_0x2b2ef0['shift']());}};_0x27125b(++_0x3decc9);}(_0x113a,0xfd));var _0xa113=function(_0x1322bd,_0x38fecf){_0x1322bd=_0x1322bd-0x0;var _0x9d9aff=_0x113a[_0x1322bd];return _0x9d9aff;};'use strict';var _=require(_0xa113('0x0'));var md5=require(_0xa113('0x1'));var util=require(_0xa113('0x2'));var Redis=require(_0xa113('0x3'));var config=require(_0xa113('0x4'));config[_0xa113('0x5')]=_[_0xa113('0x6')](config[_0xa113('0x5')],{'host':_0xa113('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xa113('0x5')]));function ChatQueue(_0x2b026e){this['id']=_0x2b026e['id']||0x0;this['name']=_0x2b026e[_0xa113('0x8')]||'';this[_0xa113('0x9')]=_0x2b026e['timeout']||0xa;this[_0xa113('0xa')]=_0x2b026e['strategy']||_0xa113('0xb');this[_0xa113('0xc')]=_0x2b026e['Agents'];this['mapAgentsId']={};this[_0xa113('0xd')]=0x0;this['md5']='';this['updateRouting']();this[_0xa113('0xe')]();}ChatQueue[_0xa113('0xf')]['updateRouting']=function(){var _0x24f58a=this[_0xa113('0x10')]['_rr'];this[_0xa113('0x10')]=_['map'](this[_0xa113('0xc')],'id');this[_0xa113('0x10')][_0xa113('0x11')]=_0x24f58a;};ChatQueue[_0xa113('0xf')]['updateRealtime']=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x2a5a6a=0x0;_0x2a5a6a<this[_0xa113('0xc')][_0xa113('0x12')];_0x2a5a6a+=0x1){if(this[_0xa113('0xc')][_0x2a5a6a]['online']){this['loggedIn']+=0x1;}if(this[_0xa113('0xc')][_0x2a5a6a][_0xa113('0x13')]){this['paused']+=0x1;}}this[_0xa113('0x14')]=this[_0xa113('0x15')]-this[_0xa113('0x16')];this['available']=this[_0xa113('0x14')]>=0x0?this['available']:0x0;var _0x100cfa={'id':this['id'],'available':this['available'],'loggedIn':this[_0xa113('0x15')],'name':this['name'],'paused':this['paused'],'waiting':this[_0xa113('0xd')]};var _0x13169c=md5(JSON['stringify'](_0x100cfa));if(this[_0xa113('0x1')]!==_0x13169c){this['md5']=_0x13169c;io['to'](util['format'](_0xa113('0x17'),_0x100cfa['name']))['emit'](_0xa113('0x18'),_0x100cfa);}};module['exports']=ChatQueue;