eca7a763c4e24ec24413c2e2066ae77f30461571
[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 _0x0b5c=['chatPause','paused','available','stringify','chat:queue:%s','chat_queue:save','exports','md5','util','ioredis','../../../config/environment','redis','localhost','name','timeout','strategy','beepall','mapAgentsId','waiting','updateRealtime','prototype','updateRouting','_rr','map','Agents','online','loggedIn'];(function(_0xca1585,_0x219dfb){var _0x117736=function(_0x386c85){while(--_0x386c85){_0xca1585['push'](_0xca1585['shift']());}};_0x117736(++_0x219dfb);}(_0x0b5c,0x166));var _0xc0b5=function(_0x179657,_0x11a4a2){_0x179657=_0x179657-0x0;var _0x4dbc2d=_0x0b5c[_0x179657];return _0x4dbc2d;};'use strict';var _=require('lodash');var md5=require(_0xc0b5('0x0'));var util=require(_0xc0b5('0x1'));var Redis=require(_0xc0b5('0x2'));var config=require(_0xc0b5('0x3'));config[_0xc0b5('0x4')]=_['defaults'](config['redis'],{'host':_0xc0b5('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function ChatQueue(_0x2978c0){this['id']=_0x2978c0['id']||0x0;this[_0xc0b5('0x6')]=_0x2978c0[_0xc0b5('0x6')]||'';this[_0xc0b5('0x7')]=_0x2978c0['timeout']||0xa;this[_0xc0b5('0x8')]=_0x2978c0[_0xc0b5('0x8')]||_0xc0b5('0x9');this['Agents']=_0x2978c0['Agents'];this[_0xc0b5('0xa')]={};this[_0xc0b5('0xb')]=0x0;this[_0xc0b5('0x0')]='';this['updateRouting']();this[_0xc0b5('0xc')]();}ChatQueue[_0xc0b5('0xd')][_0xc0b5('0xe')]=function(){var _0x311b10=this[_0xc0b5('0xa')][_0xc0b5('0xf')];this['mapAgentsId']=_[_0xc0b5('0x10')](this[_0xc0b5('0x11')],'id');this[_0xc0b5('0xa')][_0xc0b5('0xf')]=_0x311b10;};ChatQueue[_0xc0b5('0xd')][_0xc0b5('0xc')]=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x2939a1=0x0;_0x2939a1<this[_0xc0b5('0x11')]['length'];_0x2939a1+=0x1){if(this[_0xc0b5('0x11')][_0x2939a1][_0xc0b5('0x12')]){this[_0xc0b5('0x13')]+=0x1;}if(this[_0xc0b5('0x11')][_0x2939a1][_0xc0b5('0x14')]){this[_0xc0b5('0x15')]+=0x1;}}this['available']=this[_0xc0b5('0x13')]-this[_0xc0b5('0x15')];this[_0xc0b5('0x16')]=this[_0xc0b5('0x16')]>=0x0?this[_0xc0b5('0x16')]:0x0;var _0x289fca={'id':this['id'],'available':this[_0xc0b5('0x16')],'loggedIn':this['loggedIn'],'name':this[_0xc0b5('0x6')],'paused':this[_0xc0b5('0x15')],'waiting':this[_0xc0b5('0xb')]};var _0x18ba03=md5(JSON[_0xc0b5('0x17')](_0x289fca));if(this[_0xc0b5('0x0')]!==_0x18ba03){this['md5']=_0x18ba03;io['to'](util['format'](_0xc0b5('0x18'),_0x289fca[_0xc0b5('0x6')]))['emit'](_0xc0b5('0x19'),_0x289fca);}};module[_0xc0b5('0x1a')]=ChatQueue;