Built motion from commit 53172ac8.|2.6.30
[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 _0x9759=['updateRealtime','prototype','mapAgentsId','_rr','map','Agents','loggedIn','paused','online','available','stringify','format','chat:queue:%s','emit','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','waiting','updateRouting'];(function(_0x2ab365,_0xa3812e){var _0x49fef3=function(_0x29b883){while(--_0x29b883){_0x2ab365['push'](_0x2ab365['shift']());}};_0x49fef3(++_0xa3812e);}(_0x9759,0x15f));var _0x9975=function(_0x124e0c,_0x1cab8b){_0x124e0c=_0x124e0c-0x0;var _0x15fc88=_0x9759[_0x124e0c];return _0x15fc88;};'use strict';var _=require(_0x9975('0x0'));var md5=require(_0x9975('0x1'));var util=require(_0x9975('0x2'));var Redis=require(_0x9975('0x3'));var config=require(_0x9975('0x4'));config[_0x9975('0x5')]=_[_0x9975('0x6')](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0x9975('0x7'))(new Redis(config['redis']));function ChatQueue(_0x315f7b){this['id']=_0x315f7b['id']||0x0;this[_0x9975('0x8')]=_0x315f7b['name']||'';this[_0x9975('0x9')]=_0x315f7b['timeout']||0xa;this[_0x9975('0xa')]=_0x315f7b[_0x9975('0xa')]||'beepall';this['Agents']=_0x315f7b['Agents'];this['mapAgentsId']={};this[_0x9975('0xb')]=0x0;this[_0x9975('0x1')]='';this[_0x9975('0xc')]();this[_0x9975('0xd')]();}ChatQueue[_0x9975('0xe')]['updateRouting']=function(){var _0x194985=this[_0x9975('0xf')][_0x9975('0x10')];this[_0x9975('0xf')]=_[_0x9975('0x11')](this[_0x9975('0x12')],'id');this[_0x9975('0xf')][_0x9975('0x10')]=_0x194985;};ChatQueue['prototype'][_0x9975('0xd')]=function(){this[_0x9975('0x13')]=0x0;this[_0x9975('0x14')]=0x0;for(var _0x3a17c3=0x0;_0x3a17c3<this[_0x9975('0x12')]['length'];_0x3a17c3+=0x1){if(this['Agents'][_0x3a17c3][_0x9975('0x15')]){this[_0x9975('0x13')]+=0x1;}if(this[_0x9975('0x12')][_0x3a17c3]['chatPause']){this[_0x9975('0x14')]+=0x1;}}this['available']=this['loggedIn']-this[_0x9975('0x14')];this['available']=this[_0x9975('0x16')]>=0x0?this[_0x9975('0x16')]:0x0;var _0x3afe08={'id':this['id'],'available':this[_0x9975('0x16')],'loggedIn':this['loggedIn'],'name':this[_0x9975('0x8')],'paused':this['paused'],'waiting':this[_0x9975('0xb')]};var _0x5be3c8=md5(JSON[_0x9975('0x17')](_0x3afe08));if(this[_0x9975('0x1')]!==_0x5be3c8){this[_0x9975('0x1')]=_0x5be3c8;io['to'](util[_0x9975('0x18')](_0x9975('0x19'),_0x3afe08[_0x9975('0x8')]))[_0x9975('0x1a')]('chat_queue:save',_0x3afe08);}};module[_0x9975('0x1b')]=ChatQueue;