c67c7e72055273213e46159469213ea2bf786550
[motion2.git] / server / services / routing / model / smsQueue.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 _0xb90d=['sms_queue:save','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','updateRouting','updateRealtime','prototype','_rr','mapAgentsId','map','length','loggedIn','available','paused','stringify','format','sms:queue:%s','emit'];(function(_0x53acc6,_0x351a19){var _0x195e4b=function(_0x1281d2){while(--_0x1281d2){_0x53acc6['push'](_0x53acc6['shift']());}};_0x195e4b(++_0x351a19);}(_0xb90d,0x17a));var _0xdb90=function(_0x40c6a7,_0x4fc99d){_0x40c6a7=_0x40c6a7-0x0;var _0x37f57d=_0xb90d[_0x40c6a7];return _0x37f57d;};'use strict';var _=require('lodash');var md5=require(_0xdb90('0x0'));var util=require(_0xdb90('0x1'));var Redis=require(_0xdb90('0x2'));var config=require(_0xdb90('0x3'));config[_0xdb90('0x4')]=_[_0xdb90('0x5')](config['redis'],{'host':_0xdb90('0x6'),'port':0x18eb});var io=require(_0xdb90('0x7'))(new Redis(config[_0xdb90('0x4')]));function SmsQueue(_0x532dbc){this['id']=_0x532dbc['id']||0x0;this['name']=_0x532dbc[_0xdb90('0x8')]||'';this[_0xdb90('0x9')]=_0x532dbc[_0xdb90('0x9')]||0xa;this[_0xdb90('0xa')]=_0x532dbc['strategy']||_0xdb90('0xb');this[_0xdb90('0xc')]=_0x532dbc[_0xdb90('0xc')];this['mapAgentsId']={};this[_0xdb90('0xd')]=0x0;this[_0xdb90('0x0')]='';this[_0xdb90('0xe')]();this[_0xdb90('0xf')]();}SmsQueue[_0xdb90('0x10')]['updateRouting']=function(){var _0x597572=this['mapAgentsId'][_0xdb90('0x11')];this[_0xdb90('0x12')]=_[_0xdb90('0x13')](this[_0xdb90('0xc')],'id');this[_0xdb90('0x12')][_0xdb90('0x11')]=_0x597572;};SmsQueue['prototype']['updateRealtime']=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x569d40=0x0;_0x569d40<this['Agents'][_0xdb90('0x14')];_0x569d40+=0x1){if(this[_0xdb90('0xc')][_0x569d40]['online']){this[_0xdb90('0x15')]+=0x1;}if(this[_0xdb90('0xc')][_0x569d40]['smsPause']){this['paused']+=0x1;}}this[_0xdb90('0x16')]=this[_0xdb90('0x15')]-this[_0xdb90('0x17')];this['available']=this[_0xdb90('0x16')]>=0x0?this[_0xdb90('0x16')]:0x0;var _0xd50abd={'id':this['id'],'available':this[_0xdb90('0x16')],'loggedIn':this[_0xdb90('0x15')],'name':this[_0xdb90('0x8')],'paused':this[_0xdb90('0x17')],'waiting':this[_0xdb90('0xd')]};var _0x19e1bf=md5(JSON[_0xdb90('0x18')](_0xd50abd));if(this['md5']!==_0x19e1bf){this['md5']=_0x19e1bf;io['to'](util[_0xdb90('0x19')](_0xdb90('0x1a'),_0xd50abd[_0xdb90('0x8')]))[_0xdb90('0x1b')](_0xdb90('0x1c'),_0xd50abd);}};module['exports']=SmsQueue;