763c69e1380589695319d7980dc9ccf23293dfee
[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 _0xc5c9=['online','chatPause','available','stringify','format','emit','chat_queue:save','exports','lodash','md5','ioredis','../../../config/environment','defaults','redis','socket.io-emitter','name','timeout','strategy','mapAgentsId','waiting','updateRealtime','prototype','updateRouting','_rr','map','Agents','loggedIn','paused','length'];(function(_0x29a9d4,_0x492d05){var _0x2fbf19=function(_0x3c661c){while(--_0x3c661c){_0x29a9d4['push'](_0x29a9d4['shift']());}};_0x2fbf19(++_0x492d05);}(_0xc5c9,0x164));var _0x9c5c=function(_0x32c790,_0x10d864){_0x32c790=_0x32c790-0x0;var _0x596d5d=_0xc5c9[_0x32c790];return _0x596d5d;};'use strict';var _=require(_0x9c5c('0x0'));var md5=require(_0x9c5c('0x1'));var util=require('util');var Redis=require(_0x9c5c('0x2'));var config=require(_0x9c5c('0x3'));config['redis']=_[_0x9c5c('0x4')](config[_0x9c5c('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0x9c5c('0x6'))(new Redis(config[_0x9c5c('0x5')]));function ChatQueue(_0x1e2969){this['id']=_0x1e2969['id']||0x0;this['name']=_0x1e2969[_0x9c5c('0x7')]||'';this[_0x9c5c('0x8')]=_0x1e2969['timeout']||0xa;this[_0x9c5c('0x9')]=_0x1e2969[_0x9c5c('0x9')]||'beepall';this['Agents']=_0x1e2969['Agents'];this[_0x9c5c('0xa')]={};this[_0x9c5c('0xb')]=0x0;this['md5']='';this['updateRouting']();this[_0x9c5c('0xc')]();}ChatQueue[_0x9c5c('0xd')][_0x9c5c('0xe')]=function(){var _0x4873b6=this[_0x9c5c('0xa')][_0x9c5c('0xf')];this['mapAgentsId']=_[_0x9c5c('0x10')](this[_0x9c5c('0x11')],'id');this[_0x9c5c('0xa')]['_rr']=_0x4873b6;};ChatQueue[_0x9c5c('0xd')][_0x9c5c('0xc')]=function(){this[_0x9c5c('0x12')]=0x0;this[_0x9c5c('0x13')]=0x0;for(var _0x30e07c=0x0;_0x30e07c<this[_0x9c5c('0x11')][_0x9c5c('0x14')];_0x30e07c+=0x1){if(this[_0x9c5c('0x11')][_0x30e07c][_0x9c5c('0x15')]){this[_0x9c5c('0x12')]+=0x1;}if(this[_0x9c5c('0x11')][_0x30e07c][_0x9c5c('0x16')]){this[_0x9c5c('0x13')]+=0x1;}}this[_0x9c5c('0x17')]=this[_0x9c5c('0x12')]-this[_0x9c5c('0x13')];this[_0x9c5c('0x17')]=this[_0x9c5c('0x17')]>=0x0?this[_0x9c5c('0x17')]:0x0;var _0x2c8236={'id':this['id'],'available':this[_0x9c5c('0x17')],'loggedIn':this[_0x9c5c('0x12')],'name':this['name'],'paused':this[_0x9c5c('0x13')],'waiting':this['waiting']};var _0x354ce6=md5(JSON[_0x9c5c('0x18')](_0x2c8236));if(this['md5']!==_0x354ce6){this[_0x9c5c('0x1')]=_0x354ce6;io['to'](util[_0x9c5c('0x19')]('chat:queue:%s',_0x2c8236[_0x9c5c('0x7')]))[_0x9c5c('0x1a')](_0x9c5c('0x1b'),_0x2c8236);}};module[_0x9c5c('0x1c')]=ChatQueue;