6916d97bb3af6ca81ddbdcbb0e6b17a6728f9235
[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 _0xf403=['sms:queue:%s','emit','sms_queue:save','lodash','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRealtime','prototype','updateRouting','_rr','loggedIn','length','online','smsPause','paused','available','md5','format'];(function(_0x5b5eef,_0x3303f9){var _0xa0e915=function(_0x2fba87){while(--_0x2fba87){_0x5b5eef['push'](_0x5b5eef['shift']());}};_0xa0e915(++_0x3303f9);}(_0xf403,0x1d3));var _0x3f40=function(_0x1b173a,_0x1aeeba){_0x1b173a=_0x1b173a-0x0;var _0x3757f5=_0xf403[_0x1b173a];return _0x3757f5;};'use strict';var _=require(_0x3f40('0x0'));var md5=require('md5');var util=require(_0x3f40('0x1'));var Redis=require(_0x3f40('0x2'));var config=require(_0x3f40('0x3'));config[_0x3f40('0x4')]=_[_0x3f40('0x5')](config[_0x3f40('0x4')],{'host':_0x3f40('0x6'),'port':0x18eb});var io=require(_0x3f40('0x7'))(new Redis(config['redis']));function SmsQueue(_0x4e91bb){this['id']=_0x4e91bb['id']||0x0;this[_0x3f40('0x8')]=_0x4e91bb[_0x3f40('0x8')]||'';this[_0x3f40('0x9')]=_0x4e91bb[_0x3f40('0x9')]||0xa;this['strategy']=_0x4e91bb[_0x3f40('0xa')]||'beepall';this['Agents']=_0x4e91bb[_0x3f40('0xb')];this[_0x3f40('0xc')]={};this[_0x3f40('0xd')]=0x0;this['md5']='';this['updateRouting']();this[_0x3f40('0xe')]();}SmsQueue[_0x3f40('0xf')][_0x3f40('0x10')]=function(){var _0x4e30e2=this[_0x3f40('0xc')][_0x3f40('0x11')];this[_0x3f40('0xc')]=_['map'](this[_0x3f40('0xb')],'id');this['mapAgentsId'][_0x3f40('0x11')]=_0x4e30e2;};SmsQueue[_0x3f40('0xf')][_0x3f40('0xe')]=function(){this[_0x3f40('0x12')]=0x0;this['paused']=0x0;for(var _0x2b2bfe=0x0;_0x2b2bfe<this[_0x3f40('0xb')][_0x3f40('0x13')];_0x2b2bfe+=0x1){if(this[_0x3f40('0xb')][_0x2b2bfe][_0x3f40('0x14')]){this['loggedIn']+=0x1;}if(this[_0x3f40('0xb')][_0x2b2bfe][_0x3f40('0x15')]){this['paused']+=0x1;}}this['available']=this['loggedIn']-this[_0x3f40('0x16')];this[_0x3f40('0x17')]=this[_0x3f40('0x17')]>=0x0?this[_0x3f40('0x17')]:0x0;var _0x374644={'id':this['id'],'available':this['available'],'loggedIn':this[_0x3f40('0x12')],'name':this[_0x3f40('0x8')],'paused':this[_0x3f40('0x16')],'waiting':this[_0x3f40('0xd')]};var _0x3129e2=md5(JSON['stringify'](_0x374644));if(this[_0x3f40('0x18')]!==_0x3129e2){this['md5']=_0x3129e2;io['to'](util[_0x3f40('0x19')](_0x3f40('0x1a'),_0x374644[_0x3f40('0x8')]))[_0x3f40('0x1b')](_0x3f40('0x1c'),_0x374644);}};module['exports']=SmsQueue;