Built motion from commit fd055180.|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 _0xa26a=['strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','_rr','map','prototype','loggedIn','paused','length','online','available','stringify','md5','chat:queue:%s','emit','chat_queue:save','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout'];(function(_0x4da3de,_0x532168){var _0x5ac4c0=function(_0x313ab5){while(--_0x313ab5){_0x4da3de['push'](_0x4da3de['shift']());}};_0x5ac4c0(++_0x532168);}(_0xa26a,0x147));var _0xaa26=function(_0x55b49a,_0x31c0c6){_0x55b49a=_0x55b49a-0x0;var _0x4ec8f2=_0xa26a[_0x55b49a];return _0x4ec8f2;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0xaa26('0x0'));var Redis=require(_0xaa26('0x1'));var config=require(_0xaa26('0x2'));config[_0xaa26('0x3')]=_[_0xaa26('0x4')](config[_0xaa26('0x3')],{'host':_0xaa26('0x5'),'port':0x18eb});var io=require(_0xaa26('0x6'))(new Redis(config[_0xaa26('0x3')]));function ChatQueue(_0x4a10ac){this['id']=_0x4a10ac['id']||0x0;this['name']=_0x4a10ac[_0xaa26('0x7')]||'';this[_0xaa26('0x8')]=_0x4a10ac[_0xaa26('0x8')]||0xa;this[_0xaa26('0x9')]=_0x4a10ac[_0xaa26('0x9')]||_0xaa26('0xa');this[_0xaa26('0xb')]=_0x4a10ac['Agents'];this[_0xaa26('0xc')]={};this['waiting']=0x0;this['md5']='';this[_0xaa26('0xd')]();this[_0xaa26('0xe')]();}ChatQueue['prototype'][_0xaa26('0xd')]=function(){var _0x3cc1bd=this['mapAgentsId'][_0xaa26('0xf')];this[_0xaa26('0xc')]=_[_0xaa26('0x10')](this[_0xaa26('0xb')],'id');this['mapAgentsId'][_0xaa26('0xf')]=_0x3cc1bd;};ChatQueue[_0xaa26('0x11')]['updateRealtime']=function(){this[_0xaa26('0x12')]=0x0;this[_0xaa26('0x13')]=0x0;for(var _0x43c568=0x0;_0x43c568<this['Agents'][_0xaa26('0x14')];_0x43c568+=0x1){if(this[_0xaa26('0xb')][_0x43c568][_0xaa26('0x15')]){this['loggedIn']+=0x1;}if(this[_0xaa26('0xb')][_0x43c568]['chatPause']){this[_0xaa26('0x13')]+=0x1;}}this[_0xaa26('0x16')]=this['loggedIn']-this['paused'];this[_0xaa26('0x16')]=this[_0xaa26('0x16')]>=0x0?this[_0xaa26('0x16')]:0x0;var _0x47d2ff={'id':this['id'],'available':this[_0xaa26('0x16')],'loggedIn':this[_0xaa26('0x12')],'name':this[_0xaa26('0x7')],'paused':this[_0xaa26('0x13')],'waiting':this['waiting']};var _0x87bd17=md5(JSON[_0xaa26('0x17')](_0x47d2ff));if(this[_0xaa26('0x18')]!==_0x87bd17){this[_0xaa26('0x18')]=_0x87bd17;io['to'](util['format'](_0xaa26('0x19'),_0x47d2ff[_0xaa26('0x7')]))[_0xaa26('0x1a')](_0xaa26('0x1b'),_0x47d2ff);}};module['exports']=ChatQueue;