Built motion from commit b5413ace.|2.6.9
[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 _0x2ec7=['length','online','loggedIn','chatPause','available','stringify','chat_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','paused'];(function(_0x13e301,_0x13c289){var _0x124546=function(_0x53546e){while(--_0x53546e){_0x13e301['push'](_0x13e301['shift']());}};_0x124546(++_0x13c289);}(_0x2ec7,0x12a));var _0x72ec=function(_0x8c43de,_0x90ff31){_0x8c43de=_0x8c43de-0x0;var _0xa6591b=_0x2ec7[_0x8c43de];return _0xa6591b;};'use strict';var _=require(_0x72ec('0x0'));var md5=require(_0x72ec('0x1'));var util=require(_0x72ec('0x2'));var Redis=require(_0x72ec('0x3'));var config=require(_0x72ec('0x4'));config[_0x72ec('0x5')]=_[_0x72ec('0x6')](config[_0x72ec('0x5')],{'host':_0x72ec('0x7'),'port':0x18eb});var io=require(_0x72ec('0x8'))(new Redis(config[_0x72ec('0x5')]));function ChatQueue(_0x44424d){this['id']=_0x44424d['id']||0x0;this[_0x72ec('0x9')]=_0x44424d[_0x72ec('0x9')]||'';this['timeout']=_0x44424d[_0x72ec('0xa')]||0xa;this[_0x72ec('0xb')]=_0x44424d[_0x72ec('0xb')]||'beepall';this[_0x72ec('0xc')]=_0x44424d['Agents'];this[_0x72ec('0xd')]={};this[_0x72ec('0xe')]=0x0;this[_0x72ec('0x1')]='';this[_0x72ec('0xf')]();this[_0x72ec('0x10')]();}ChatQueue[_0x72ec('0x11')][_0x72ec('0xf')]=function(){var _0x3439be=this[_0x72ec('0xd')][_0x72ec('0x12')];this[_0x72ec('0xd')]=_[_0x72ec('0x13')](this[_0x72ec('0xc')],'id');this[_0x72ec('0xd')][_0x72ec('0x12')]=_0x3439be;};ChatQueue[_0x72ec('0x11')][_0x72ec('0x10')]=function(){this['loggedIn']=0x0;this[_0x72ec('0x14')]=0x0;for(var _0x53cf75=0x0;_0x53cf75<this[_0x72ec('0xc')][_0x72ec('0x15')];_0x53cf75+=0x1){if(this['Agents'][_0x53cf75][_0x72ec('0x16')]){this[_0x72ec('0x17')]+=0x1;}if(this[_0x72ec('0xc')][_0x53cf75][_0x72ec('0x18')]){this[_0x72ec('0x14')]+=0x1;}}this[_0x72ec('0x19')]=this[_0x72ec('0x17')]-this[_0x72ec('0x14')];this[_0x72ec('0x19')]=this[_0x72ec('0x19')]>=0x0?this['available']:0x0;var _0x4ec615={'id':this['id'],'available':this['available'],'loggedIn':this[_0x72ec('0x17')],'name':this['name'],'paused':this[_0x72ec('0x14')],'waiting':this[_0x72ec('0xe')]};var _0x2b388c=md5(JSON[_0x72ec('0x1a')](_0x4ec615));if(this[_0x72ec('0x1')]!==_0x2b388c){this['md5']=_0x2b388c;io['to'](util['format']('chat:queue:%s',_0x4ec615['name']))['emit'](_0x72ec('0x1b'),_0x4ec615);}};module[_0x72ec('0x1c')]=ChatQueue;