f951f4349860a8e278cf491752d0496187bdd966
[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 _0x0eac=['beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','map','loggedIn','paused','online','chatPause','available','stringify','format','chat:queue:%s','emit','chat_queue:save','exports','md5','ioredis','redis','defaults','socket.io-emitter','name','timeout','strategy'];(function(_0x3b2147,_0x3ffcd9){var _0x7a0b6a=function(_0x4b01ed){while(--_0x4b01ed){_0x3b2147['push'](_0x3b2147['shift']());}};_0x7a0b6a(++_0x3ffcd9);}(_0x0eac,0x13c));var _0xc0ea=function(_0x3c4dad,_0x25ffd5){_0x3c4dad=_0x3c4dad-0x0;var _0x1a4f49=_0x0eac[_0x3c4dad];return _0x1a4f49;};'use strict';var _=require('lodash');var md5=require(_0xc0ea('0x0'));var util=require('util');var Redis=require(_0xc0ea('0x1'));var config=require('../../../config/environment');config[_0xc0ea('0x2')]=_[_0xc0ea('0x3')](config[_0xc0ea('0x2')],{'host':'localhost','port':0x18eb});var io=require(_0xc0ea('0x4'))(new Redis(config[_0xc0ea('0x2')]));function ChatQueue(_0x4c846a){this['id']=_0x4c846a['id']||0x0;this['name']=_0x4c846a[_0xc0ea('0x5')]||'';this[_0xc0ea('0x6')]=_0x4c846a[_0xc0ea('0x6')]||0xa;this['strategy']=_0x4c846a[_0xc0ea('0x7')]||_0xc0ea('0x8');this['Agents']=_0x4c846a[_0xc0ea('0x9')];this[_0xc0ea('0xa')]={};this[_0xc0ea('0xb')]=0x0;this['md5']='';this[_0xc0ea('0xc')]();this[_0xc0ea('0xd')]();}ChatQueue[_0xc0ea('0xe')][_0xc0ea('0xc')]=function(){var _0x43e0b9=this[_0xc0ea('0xa')]['_rr'];this['mapAgentsId']=_[_0xc0ea('0xf')](this[_0xc0ea('0x9')],'id');this[_0xc0ea('0xa')]['_rr']=_0x43e0b9;};ChatQueue['prototype']['updateRealtime']=function(){this[_0xc0ea('0x10')]=0x0;this[_0xc0ea('0x11')]=0x0;for(var _0x4f4467=0x0;_0x4f4467<this[_0xc0ea('0x9')]['length'];_0x4f4467+=0x1){if(this[_0xc0ea('0x9')][_0x4f4467][_0xc0ea('0x12')]){this['loggedIn']+=0x1;}if(this[_0xc0ea('0x9')][_0x4f4467][_0xc0ea('0x13')]){this[_0xc0ea('0x11')]+=0x1;}}this[_0xc0ea('0x14')]=this[_0xc0ea('0x10')]-this['paused'];this[_0xc0ea('0x14')]=this['available']>=0x0?this[_0xc0ea('0x14')]:0x0;var _0xe73bfa={'id':this['id'],'available':this[_0xc0ea('0x14')],'loggedIn':this['loggedIn'],'name':this[_0xc0ea('0x5')],'paused':this[_0xc0ea('0x11')],'waiting':this[_0xc0ea('0xb')]};var _0x5f0637=md5(JSON[_0xc0ea('0x15')](_0xe73bfa));if(this[_0xc0ea('0x0')]!==_0x5f0637){this['md5']=_0x5f0637;io['to'](util[_0xc0ea('0x16')](_0xc0ea('0x17'),_0xe73bfa['name']))[_0xc0ea('0x18')](_0xc0ea('0x19'),_0xe73bfa);}};module[_0xc0ea('0x1a')]=ChatQueue;