Built motion from commit (unavailable).|2.5.11
[motion2.git] / server / services / routing / model / openchannelQueue.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 _0xe650=['lodash','md5','util','redis','defaults','localhost','socket.io-emitter','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','_rr','map','prototype','loggedIn','paused','length','available','name','format','openchannel:queue:%s','emit','exports'];(function(_0x4573bd,_0x19b9b5){var _0xc07bb9=function(_0x36a36a){while(--_0x36a36a){_0x4573bd['push'](_0x4573bd['shift']());}};_0xc07bb9(++_0x19b9b5);}(_0xe650,0x6c));var _0x0e65=function(_0x7e3bb8,_0x27c048){_0x7e3bb8=_0x7e3bb8-0x0;var _0x44c887=_0xe650[_0x7e3bb8];return _0x44c887;};'use strict';var _=require(_0x0e65('0x0'));var md5=require(_0x0e65('0x1'));var util=require(_0x0e65('0x2'));var Redis=require('ioredis');var config=require('../../../config/environment');config[_0x0e65('0x3')]=_[_0x0e65('0x4')](config[_0x0e65('0x3')],{'host':_0x0e65('0x5'),'port':0x18eb});var io=require(_0x0e65('0x6'))(new Redis(config[_0x0e65('0x3')]));function OpenchannelQueue(_0xfe2a86){this['id']=_0xfe2a86['id']||0x0;this['name']=_0xfe2a86['name']||'';this['timeout']=_0xfe2a86[_0x0e65('0x7')]||0xa;this[_0x0e65('0x8')]=_0xfe2a86[_0x0e65('0x8')]||_0x0e65('0x9');this[_0x0e65('0xa')]=_0xfe2a86['Agents'];this[_0x0e65('0xb')]={};this[_0x0e65('0xc')]=0x0;this[_0x0e65('0x1')]='';this[_0x0e65('0xd')]();this[_0x0e65('0xe')]();}OpenchannelQueue['prototype']['updateRouting']=function(){var _0x6ca3c9=this[_0x0e65('0xb')][_0x0e65('0xf')];this[_0x0e65('0xb')]=_[_0x0e65('0x10')](this[_0x0e65('0xa')],'id');this[_0x0e65('0xb')][_0x0e65('0xf')]=_0x6ca3c9;};OpenchannelQueue[_0x0e65('0x11')][_0x0e65('0xe')]=function(){this[_0x0e65('0x12')]=0x0;this[_0x0e65('0x13')]=0x0;for(var _0x1338f7=0x0;_0x1338f7<this['Agents'][_0x0e65('0x14')];_0x1338f7+=0x1){if(this[_0x0e65('0xa')][_0x1338f7]['online']){this[_0x0e65('0x12')]+=0x1;}if(this[_0x0e65('0xa')][_0x1338f7]['openchannelPause']){this['paused']+=0x1;}}this[_0x0e65('0x15')]=this[_0x0e65('0x12')]-this[_0x0e65('0x13')];this['available']=this[_0x0e65('0x15')]>=0x0?this[_0x0e65('0x15')]:0x0;var _0x1f50d2={'id':this['id'],'available':this[_0x0e65('0x15')],'loggedIn':this[_0x0e65('0x12')],'name':this[_0x0e65('0x16')],'paused':this[_0x0e65('0x13')],'waiting':this[_0x0e65('0xc')]};var _0x287776=md5(JSON['stringify'](_0x1f50d2));if(this[_0x0e65('0x1')]!==_0x287776){this[_0x0e65('0x1')]=_0x287776;io['to'](util[_0x0e65('0x17')](_0x0e65('0x18'),_0x1f50d2[_0x0e65('0x16')]))[_0x0e65('0x19')]('openchannel_queue:save',_0x1f50d2);}};module[_0x0e65('0x1a')]=OpenchannelQueue;