Built motion from commit (unavailable).|2.3.4
[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 _0xc06f=['loggedIn','paused','length','online','chatPause','available','format','chat:queue:%s','emit','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','_rr'];(function(_0x337a10,_0x5191c7){var _0x575f98=function(_0x3851cd){while(--_0x3851cd){_0x337a10['push'](_0x337a10['shift']());}};_0x575f98(++_0x5191c7);}(_0xc06f,0x1ae));var _0xfc06=function(_0x42280d,_0xfe2682){_0x42280d=_0x42280d-0x0;var _0x3707cb=_0xc06f[_0x42280d];return _0x3707cb;};'use strict';var _=require(_0xfc06('0x0'));var md5=require(_0xfc06('0x1'));var util=require(_0xfc06('0x2'));var Redis=require(_0xfc06('0x3'));var config=require(_0xfc06('0x4'));config[_0xfc06('0x5')]=_[_0xfc06('0x6')](config[_0xfc06('0x5')],{'host':_0xfc06('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function ChatQueue(_0x56b803){this['id']=_0x56b803['id']||0x0;this['name']=_0x56b803[_0xfc06('0x8')]||'';this[_0xfc06('0x9')]=_0x56b803[_0xfc06('0x9')]||0xa;this['strategy']=_0x56b803[_0xfc06('0xa')]||_0xfc06('0xb');this[_0xfc06('0xc')]=_0x56b803[_0xfc06('0xc')];this[_0xfc06('0xd')]={};this[_0xfc06('0xe')]=0x0;this[_0xfc06('0x1')]='';this[_0xfc06('0xf')]();this[_0xfc06('0x10')]();}ChatQueue['prototype'][_0xfc06('0xf')]=function(){var _0x1097ce=this[_0xfc06('0xd')][_0xfc06('0x11')];this[_0xfc06('0xd')]=_['map'](this[_0xfc06('0xc')],'id');this['mapAgentsId'][_0xfc06('0x11')]=_0x1097ce;};ChatQueue['prototype'][_0xfc06('0x10')]=function(){this[_0xfc06('0x12')]=0x0;this[_0xfc06('0x13')]=0x0;for(var _0x476260=0x0;_0x476260<this[_0xfc06('0xc')][_0xfc06('0x14')];_0x476260+=0x1){if(this['Agents'][_0x476260][_0xfc06('0x15')]){this[_0xfc06('0x12')]+=0x1;}if(this[_0xfc06('0xc')][_0x476260][_0xfc06('0x16')]){this[_0xfc06('0x13')]+=0x1;}}this[_0xfc06('0x17')]=this[_0xfc06('0x12')]-this[_0xfc06('0x13')];this[_0xfc06('0x17')]=this[_0xfc06('0x17')]>=0x0?this[_0xfc06('0x17')]:0x0;var _0x3dd592={'id':this['id'],'available':this[_0xfc06('0x17')],'loggedIn':this[_0xfc06('0x12')],'name':this[_0xfc06('0x8')],'paused':this[_0xfc06('0x13')],'waiting':this['waiting']};var _0x3896c4=md5(JSON['stringify'](_0x3dd592));if(this[_0xfc06('0x1')]!==_0x3896c4){this[_0xfc06('0x1')]=_0x3896c4;io['to'](util[_0xfc06('0x18')](_0xfc06('0x19'),_0x3dd592[_0xfc06('0x8')]))[_0xfc06('0x1a')]('chat_queue:save',_0x3dd592);}};module[_0xfc06('0x1b')]=ChatQueue;