Built motion from commit (unavailable).|2.5.13
[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 _0x121c=['lodash','md5','util','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','mapAgentsId','updateRouting','updateRealtime','_rr','map','Agents','prototype','loggedIn','paused','length','online','chatPause','available','waiting','stringify','format','chat:queue:%s','chat_queue:save','exports'];(function(_0x1facfa,_0x1acf7d){var _0x9ec701=function(_0x115e37){while(--_0x115e37){_0x1facfa['push'](_0x1facfa['shift']());}};_0x9ec701(++_0x1acf7d);}(_0x121c,0x15c));var _0xc121=function(_0x5c3c0b,_0x4ee35e){_0x5c3c0b=_0x5c3c0b-0x0;var _0x52ecd2=_0x121c[_0x5c3c0b];return _0x52ecd2;};'use strict';var _=require(_0xc121('0x0'));var md5=require(_0xc121('0x1'));var util=require(_0xc121('0x2'));var Redis=require('ioredis');var config=require(_0xc121('0x3'));config[_0xc121('0x4')]=_[_0xc121('0x5')](config[_0xc121('0x4')],{'host':_0xc121('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function ChatQueue(_0x1d4902){this['id']=_0x1d4902['id']||0x0;this[_0xc121('0x7')]=_0x1d4902[_0xc121('0x7')]||'';this[_0xc121('0x8')]=_0x1d4902['timeout']||0xa;this[_0xc121('0x9')]=_0x1d4902['strategy']||'beepall';this['Agents']=_0x1d4902['Agents'];this[_0xc121('0xa')]={};this['waiting']=0x0;this[_0xc121('0x1')]='';this[_0xc121('0xb')]();this[_0xc121('0xc')]();}ChatQueue['prototype'][_0xc121('0xb')]=function(){var _0x43ad5b=this[_0xc121('0xa')][_0xc121('0xd')];this['mapAgentsId']=_[_0xc121('0xe')](this[_0xc121('0xf')],'id');this[_0xc121('0xa')][_0xc121('0xd')]=_0x43ad5b;};ChatQueue[_0xc121('0x10')][_0xc121('0xc')]=function(){this[_0xc121('0x11')]=0x0;this[_0xc121('0x12')]=0x0;for(var _0x358474=0x0;_0x358474<this['Agents'][_0xc121('0x13')];_0x358474+=0x1){if(this[_0xc121('0xf')][_0x358474][_0xc121('0x14')]){this[_0xc121('0x11')]+=0x1;}if(this[_0xc121('0xf')][_0x358474][_0xc121('0x15')]){this[_0xc121('0x12')]+=0x1;}}this['available']=this['loggedIn']-this[_0xc121('0x12')];this[_0xc121('0x16')]=this[_0xc121('0x16')]>=0x0?this[_0xc121('0x16')]:0x0;var _0x530ccd={'id':this['id'],'available':this['available'],'loggedIn':this[_0xc121('0x11')],'name':this['name'],'paused':this['paused'],'waiting':this[_0xc121('0x17')]};var _0xcf511=md5(JSON[_0xc121('0x18')](_0x530ccd));if(this['md5']!==_0xcf511){this[_0xc121('0x1')]=_0xcf511;io['to'](util[_0xc121('0x19')](_0xc121('0x1a'),_0x530ccd['name']))['emit'](_0xc121('0x1b'),_0x530ccd);}};module[_0xc121('0x1c')]=ChatQueue;