eda6302933f30f95aff2c0b1773241696f6dad96
[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 _0x6095=['updateRealtime','prototype','_rr','map','Agents','loggedIn','paused','online','available','stringify','emit','exports','lodash','md5','util','redis','defaults','socket.io-emitter','name','timeout','strategy','mapAgentsId','waiting','updateRouting'];(function(_0x3d0c09,_0x348744){var _0x1be922=function(_0x4ad1c5){while(--_0x4ad1c5){_0x3d0c09['push'](_0x3d0c09['shift']());}};_0x1be922(++_0x348744);}(_0x6095,0x174));var _0x5609=function(_0x3d42d8,_0x4cffaa){_0x3d42d8=_0x3d42d8-0x0;var _0x27fc41=_0x6095[_0x3d42d8];return _0x27fc41;};'use strict';var _=require(_0x5609('0x0'));var md5=require(_0x5609('0x1'));var util=require(_0x5609('0x2'));var Redis=require('ioredis');var config=require('../../../config/environment');config[_0x5609('0x3')]=_[_0x5609('0x4')](config[_0x5609('0x3')],{'host':'localhost','port':0x18eb});var io=require(_0x5609('0x5'))(new Redis(config[_0x5609('0x3')]));function OpenchannelQueue(_0x3d134b){this['id']=_0x3d134b['id']||0x0;this[_0x5609('0x6')]=_0x3d134b['name']||'';this[_0x5609('0x7')]=_0x3d134b[_0x5609('0x7')]||0xa;this['strategy']=_0x3d134b[_0x5609('0x8')]||'beepall';this['Agents']=_0x3d134b['Agents'];this[_0x5609('0x9')]={};this[_0x5609('0xa')]=0x0;this[_0x5609('0x1')]='';this[_0x5609('0xb')]();this[_0x5609('0xc')]();}OpenchannelQueue[_0x5609('0xd')]['updateRouting']=function(){var _0x590265=this[_0x5609('0x9')][_0x5609('0xe')];this[_0x5609('0x9')]=_[_0x5609('0xf')](this[_0x5609('0x10')],'id');this[_0x5609('0x9')][_0x5609('0xe')]=_0x590265;};OpenchannelQueue[_0x5609('0xd')]['updateRealtime']=function(){this[_0x5609('0x11')]=0x0;this[_0x5609('0x12')]=0x0;for(var _0x577cf7=0x0;_0x577cf7<this[_0x5609('0x10')]['length'];_0x577cf7+=0x1){if(this[_0x5609('0x10')][_0x577cf7][_0x5609('0x13')]){this['loggedIn']+=0x1;}if(this[_0x5609('0x10')][_0x577cf7]['openchannelPause']){this[_0x5609('0x12')]+=0x1;}}this[_0x5609('0x14')]=this['loggedIn']-this[_0x5609('0x12')];this[_0x5609('0x14')]=this[_0x5609('0x14')]>=0x0?this[_0x5609('0x14')]:0x0;var _0x425f0c={'id':this['id'],'available':this[_0x5609('0x14')],'loggedIn':this['loggedIn'],'name':this[_0x5609('0x6')],'paused':this['paused'],'waiting':this[_0x5609('0xa')]};var _0x57161e=md5(JSON[_0x5609('0x15')](_0x425f0c));if(this[_0x5609('0x1')]!==_0x57161e){this[_0x5609('0x1')]=_0x57161e;io['to'](util['format']('openchannel:queue:%s',_0x425f0c[_0x5609('0x6')]))[_0x5609('0x16')]('openchannel_queue:save',_0x425f0c);}};module[_0x5609('0x17')]=OpenchannelQueue;