Built motion from commit (unavailable).|2.4.3
[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 _0x33b6=['waiting','updateRealtime','prototype','map','_rr','loggedIn','paused','length','online','chatPause','available','name','stringify','format','chat:queue:%s','emit','exports','lodash','md5','util','ioredis','redis','defaults','socket.io-emitter','timeout','strategy','beepall','Agents','mapAgentsId'];(function(_0x2dca82,_0x4c5f3e){var _0x4e47ee=function(_0xe1604c){while(--_0xe1604c){_0x2dca82['push'](_0x2dca82['shift']());}};_0x4e47ee(++_0x4c5f3e);}(_0x33b6,0xdc));var _0x633b=function(_0xe111d,_0x530bb4){_0xe111d=_0xe111d-0x0;var _0x4f8927=_0x33b6[_0xe111d];return _0x4f8927;};'use strict';var _=require(_0x633b('0x0'));var md5=require(_0x633b('0x1'));var util=require(_0x633b('0x2'));var Redis=require(_0x633b('0x3'));var config=require('../../../config/environment');config[_0x633b('0x4')]=_[_0x633b('0x5')](config[_0x633b('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x633b('0x6'))(new Redis(config[_0x633b('0x4')]));function ChatQueue(_0x68e51b){this['id']=_0x68e51b['id']||0x0;this['name']=_0x68e51b['name']||'';this[_0x633b('0x7')]=_0x68e51b[_0x633b('0x7')]||0xa;this['strategy']=_0x68e51b[_0x633b('0x8')]||_0x633b('0x9');this['Agents']=_0x68e51b[_0x633b('0xa')];this[_0x633b('0xb')]={};this[_0x633b('0xc')]=0x0;this[_0x633b('0x1')]='';this['updateRouting']();this[_0x633b('0xd')]();}ChatQueue[_0x633b('0xe')]['updateRouting']=function(){var _0x45cf4e=this[_0x633b('0xb')]['_rr'];this['mapAgentsId']=_[_0x633b('0xf')](this['Agents'],'id');this[_0x633b('0xb')][_0x633b('0x10')]=_0x45cf4e;};ChatQueue[_0x633b('0xe')][_0x633b('0xd')]=function(){this[_0x633b('0x11')]=0x0;this[_0x633b('0x12')]=0x0;for(var _0x12be9a=0x0;_0x12be9a<this[_0x633b('0xa')][_0x633b('0x13')];_0x12be9a+=0x1){if(this[_0x633b('0xa')][_0x12be9a][_0x633b('0x14')]){this[_0x633b('0x11')]+=0x1;}if(this[_0x633b('0xa')][_0x12be9a][_0x633b('0x15')]){this[_0x633b('0x12')]+=0x1;}}this[_0x633b('0x16')]=this['loggedIn']-this[_0x633b('0x12')];this[_0x633b('0x16')]=this[_0x633b('0x16')]>=0x0?this['available']:0x0;var _0x170843={'id':this['id'],'available':this[_0x633b('0x16')],'loggedIn':this[_0x633b('0x11')],'name':this[_0x633b('0x17')],'paused':this[_0x633b('0x12')],'waiting':this[_0x633b('0xc')]};var _0x55e572=md5(JSON[_0x633b('0x18')](_0x170843));if(this[_0x633b('0x1')]!==_0x55e572){this['md5']=_0x55e572;io['to'](util[_0x633b('0x19')](_0x633b('0x1a'),_0x170843[_0x633b('0x17')]))[_0x633b('0x1b')]('chat_queue:save',_0x170843);}};module[_0x633b('0x1c')]=ChatQueue;