cd0eb819e5f1d74296f8710c28b2f74a5cecc31b
[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 _0xa27d=['prototype','map','_rr','paused','length','loggedIn','chatPause','available','stringify','format','chat:queue:%s','emit','exports','lodash','util','../../../config/environment','redis','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','md5','updateRouting','updateRealtime'];(function(_0x8de006,_0x58e930){var _0x1511b4=function(_0x98f524){while(--_0x98f524){_0x8de006['push'](_0x8de006['shift']());}};_0x1511b4(++_0x58e930);}(_0xa27d,0x109));var _0xda27=function(_0x2622f2,_0xeb6538){_0x2622f2=_0x2622f2-0x0;var _0x500f5b=_0xa27d[_0x2622f2];return _0x500f5b;};'use strict';var _=require(_0xda27('0x0'));var md5=require('md5');var util=require(_0xda27('0x1'));var Redis=require('ioredis');var config=require(_0xda27('0x2'));config['redis']=_['defaults'](config[_0xda27('0x3')],{'host':'localhost','port':0x18eb});var io=require(_0xda27('0x4'))(new Redis(config[_0xda27('0x3')]));function ChatQueue(_0xb48224){this['id']=_0xb48224['id']||0x0;this[_0xda27('0x5')]=_0xb48224[_0xda27('0x5')]||'';this[_0xda27('0x6')]=_0xb48224['timeout']||0xa;this[_0xda27('0x7')]=_0xb48224[_0xda27('0x7')]||_0xda27('0x8');this['Agents']=_0xb48224[_0xda27('0x9')];this[_0xda27('0xa')]={};this[_0xda27('0xb')]=0x0;this[_0xda27('0xc')]='';this[_0xda27('0xd')]();this[_0xda27('0xe')]();}ChatQueue[_0xda27('0xf')][_0xda27('0xd')]=function(){var _0x36f366=this[_0xda27('0xa')]['_rr'];this[_0xda27('0xa')]=_[_0xda27('0x10')](this[_0xda27('0x9')],'id');this['mapAgentsId'][_0xda27('0x11')]=_0x36f366;};ChatQueue[_0xda27('0xf')][_0xda27('0xe')]=function(){this['loggedIn']=0x0;this[_0xda27('0x12')]=0x0;for(var _0x4d1df4=0x0;_0x4d1df4<this[_0xda27('0x9')][_0xda27('0x13')];_0x4d1df4+=0x1){if(this[_0xda27('0x9')][_0x4d1df4]['online']){this[_0xda27('0x14')]+=0x1;}if(this[_0xda27('0x9')][_0x4d1df4][_0xda27('0x15')]){this[_0xda27('0x12')]+=0x1;}}this[_0xda27('0x16')]=this[_0xda27('0x14')]-this[_0xda27('0x12')];this['available']=this[_0xda27('0x16')]>=0x0?this[_0xda27('0x16')]:0x0;var _0x36fa29={'id':this['id'],'available':this['available'],'loggedIn':this[_0xda27('0x14')],'name':this[_0xda27('0x5')],'paused':this[_0xda27('0x12')],'waiting':this[_0xda27('0xb')]};var _0x484ead=md5(JSON[_0xda27('0x17')](_0x36fa29));if(this[_0xda27('0xc')]!==_0x484ead){this[_0xda27('0xc')]=_0x484ead;io['to'](util[_0xda27('0x18')](_0xda27('0x19'),_0x36fa29['name']))[_0xda27('0x1a')]('chat_queue:save',_0x36fa29);}};module[_0xda27('0x1b')]=ChatQueue;