Built motion from commit 4c579f6b.|2.5.32
[motion2.git] / server / config / license / util.js
index 75ef027..1791a24 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf9d9=['getUuid','Breaking\x20license','License','find','defaults','then','uuid','data1','license','isEmpty','License\x20key\x20value\x20not\x20found','split','decryptString','format','%s:%s:%s','parse','machineUuid','gray','deadline','grayReason','changed','disabled','message','User','findAll','role','sequelize','COUNT','user','telephone','users','telephones','forEach','admin','count','countBy','License\x20limit\x20reached\x20for\x20telephones','exports','lodash','moment','bluebird','../../components/encryptor','2027-01-01T00:00:00.000Z','Demo\x20license'];(function(_0x97801c,_0xe28a34){var _0x27388c=function(_0x407f6c){while(--_0x407f6c){_0x97801c['push'](_0x97801c['shift']());}};_0x27388c(++_0xe28a34);}(_0xf9d9,0x12e));var _0x9f9d=function(_0x48fff1,_0x50c537){_0x48fff1=_0x48fff1-0x0;var _0x127a1d=_0xf9d9[_0x48fff1];return _0x127a1d;};'use strict';var util=require('util');var _=require(_0x9f9d('0x0'));var moment=require(_0x9f9d('0x1'));var BPromise=require(_0x9f9d('0x2'));var hardware=require('./hardware');var encryptor=require(_0x9f9d('0x3'));var db=require('../../mysqldb')['db'];const demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x9f9d('0x4'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':_0x9f9d('0x5'),'machineUuid':hardware[_0x9f9d('0x6')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};const breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x9f9d('0x4'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x9f9d('0x7'),'machineUuid':hardware[_0x9f9d('0x6')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0xb967ba){return new BPromise(function(_0x1a69f4,_0x4af586){return db[_0x9f9d('0x8')][_0x9f9d('0x9')](_[_0x9f9d('0xa')](_0xb967ba,{'raw':!![],'where':{'id':0x1}}))[_0x9f9d('0xb')](function(_0x41f147){return checkLicense(_0x41f147,null);})['then'](function(_0x316b80){_0x1a69f4(_0x316b80);return;})['catch'](function(_0x671ad0){_0x4af586(_0x671ad0);});});}function checkLicense(_0x328a45,_0x34a3e3){if(!_0x328a45){demoLicense[_0x9f9d('0xc')]=_0x328a45[_0x9f9d('0xd')];return demoLicense;}try{var _0x15384c=_0x34a3e3||_0x328a45[_0x9f9d('0xe')];if(_[_0x9f9d('0xf')](_0x15384c)){throw new Error(_0x9f9d('0x10'));}var _0x466e7e=_0x328a45[_0x9f9d('0xd')];var _0x2ca24f=_0x328a45['data2'];var _0x4e7b91=_0x466e7e[_0x9f9d('0x11')]('-')[0x4];var _0xd57522=_0x466e7e[_0x9f9d('0x11')]('-')[0x0];var _0x315d80=encryptor[_0x9f9d('0x12')](_0x15384c,util[_0x9f9d('0x13')](_0x9f9d('0x14'),_0x4e7b91,_0x466e7e,_0xd57522));var _0x2c3456=JSON[_0x9f9d('0x15')](_0x315d80);_0x2c3456['demo']=![];_0x2c3456['uuid']=_0x466e7e;_0x2c3456[_0x9f9d('0x16')]=hardware[_0x9f9d('0x6')]();if(_0x2ca24f){var _0x73363a=encryptor['decryptString'](_0x2ca24f);_0x2c3456[_0x9f9d('0x17')]=_0x73363a;_0x2c3456[_0x9f9d('0x18')]=moment(_0x73363a)['add'](0x7,'days')['format']();_0x2c3456[_0x9f9d('0x19')]=_0x2c3456[_0x9f9d('0xc')]!=_0x2c3456[_0x9f9d('0x16')]?_0x9f9d('0x1a'):_0x9f9d('0x1b');}return _0x2c3456;}catch(_0x5a1f88){breakingLicense[_0x9f9d('0xc')]=_0x328a45[_0x9f9d('0xd')];breakingLicense[_0x9f9d('0x1c')]=_0x5a1f88[_0x9f9d('0x1c')];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x26becc,_0x1089b2){getLicense()['then'](function(_0x4011a0){return db[_0x9f9d('0x1d')][_0x9f9d('0x1e')]({'attributes':[_0x9f9d('0x1f'),[db[_0x9f9d('0x20')]['fn'](_0x9f9d('0x21'),db[_0x9f9d('0x20')]['col'](_0x9f9d('0x1f'))),'count']],'group':_0x9f9d('0x1f'),'where':{'role':{'$or':['admin',_0x9f9d('0x22'),_0x9f9d('0x23')]}},'raw':!![]})[_0x9f9d('0xb')](function(_0x25013e){var _0x35458b={'user':_0x4011a0[_0x9f9d('0x24')]||0x0,'telephone':_0x4011a0[_0x9f9d('0x25')]||0x0};_0x25013e[_0x9f9d('0x26')](function(_0x308989){var _0x11f8a8=_0x308989[_0x9f9d('0x1f')]===_0x9f9d('0x27')?_0x9f9d('0x22'):_0x308989[_0x9f9d('0x1f')];_0x35458b[_0x11f8a8]-=_0x308989[_0x9f9d('0x28')];if(_0x35458b[_0x11f8a8]<0x0)_0x35458b[_0x11f8a8]=0x0;});_0x26becc(_0x35458b);return;});})['catch'](function(_0x4659c1){_0x1089b2(_0x4659c1);});});}function checkUserLimits(_0x154050){return new BPromise(function(_0x5756bb,_0x4a7a59){getLimits()[_0x9f9d('0xb')](function(_0x435e7d){var _0x321385=_['pick'](_[_0x9f9d('0x29')](_0x154050,_0x9f9d('0x1f')),[_0x9f9d('0x27'),'user',_0x9f9d('0x23')]);var _0x3fee28=(_0x321385[_0x9f9d('0x27')]||0x0)+(_0x321385['user']||0x0);var _0x513dce=_0x321385[_0x9f9d('0x23')]||0x0;if(_0x3fee28>_0x435e7d[_0x9f9d('0x22')])return _0x4a7a59('License\x20limit\x20reached\x20for\x20users');if(_0x513dce>_0x435e7d['telephone'])return _0x4a7a59(_0x9f9d('0x2a'));return _0x5756bb();})['catch'](function(_0x58b346){_0x4a7a59(_0x58b346);});});}module[_0x9f9d('0x2b')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file
+var _0xf940=['days','grayReason','changed','disabled','message','role','COUNT','sequelize','user','users','telephones','forEach','count','catch','pick','admin','telephone','License\x20limit\x20reached\x20for\x20telephones','exports','util','lodash','./hardware','../../components/encryptor','../../mysqldb','Demo\x20license','Breaking\x20license','getUuid','License','find','defaults','then','uuid','data1','license','isEmpty','License\x20key\x20value\x20not\x20found','data2','split','decryptString','format','%s:%s:%s','parse','demo','machineUuid','gray','deadline'];(function(_0x473450,_0x27b484){var _0x3395d4=function(_0x3ea0bd){while(--_0x3ea0bd){_0x473450['push'](_0x473450['shift']());}};_0x3395d4(++_0x27b484);}(_0xf940,0x6f));var _0x0f94=function(_0x1ab180,_0x382b2c){_0x1ab180=_0x1ab180-0x0;var _0xfb2c2d=_0xf940[_0x1ab180];return _0xfb2c2d;};'use strict';var util=require(_0x0f94('0x0'));var _=require(_0x0f94('0x1'));var moment=require('moment');var BPromise=require('bluebird');var hardware=require(_0x0f94('0x2'));var encryptor=require(_0x0f94('0x3'));var db=require(_0x0f94('0x4'))['db'];const demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':'2027-01-01T00:00:00.000Z','chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':_0x0f94('0x5'),'machineUuid':hardware['getUuid'](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};const breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':'2027-01-01T00:00:00.000Z','chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x0f94('0x6'),'machineUuid':hardware[_0x0f94('0x7')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x5f4f75){return new BPromise(function(_0x356c55,_0x3eeda1){return db[_0x0f94('0x8')][_0x0f94('0x9')](_[_0x0f94('0xa')](_0x5f4f75,{'raw':!![],'where':{'id':0x1}}))[_0x0f94('0xb')](function(_0xd74da7){return checkLicense(_0xd74da7,null);})[_0x0f94('0xb')](function(_0x40c328){_0x356c55(_0x40c328);return;})['catch'](function(_0x1dbfdb){_0x3eeda1(_0x1dbfdb);});});}function checkLicense(_0x29774d,_0x375359){if(!_0x29774d){demoLicense[_0x0f94('0xc')]=_0x29774d[_0x0f94('0xd')];return demoLicense;}try{var _0xdef609=_0x375359||_0x29774d[_0x0f94('0xe')];if(_[_0x0f94('0xf')](_0xdef609)){throw new Error(_0x0f94('0x10'));}var _0x288a64=_0x29774d['data1'];var _0x4ca936=_0x29774d[_0x0f94('0x11')];var _0x37032a=_0x288a64['split']('-')[0x4];var _0x24b153=_0x288a64[_0x0f94('0x12')]('-')[0x0];var _0x26ba22=encryptor[_0x0f94('0x13')](_0xdef609,util[_0x0f94('0x14')](_0x0f94('0x15'),_0x37032a,_0x288a64,_0x24b153));var _0x1c382b=JSON[_0x0f94('0x16')](_0x26ba22);_0x1c382b[_0x0f94('0x17')]=![];_0x1c382b[_0x0f94('0xc')]=_0x288a64;_0x1c382b[_0x0f94('0x18')]=hardware[_0x0f94('0x7')]();if(_0x4ca936){var _0x2b8b0c=encryptor[_0x0f94('0x13')](_0x4ca936);_0x1c382b[_0x0f94('0x19')]=_0x2b8b0c;_0x1c382b[_0x0f94('0x1a')]=moment(_0x2b8b0c)['add'](0x7,_0x0f94('0x1b'))[_0x0f94('0x14')]();_0x1c382b[_0x0f94('0x1c')]=_0x1c382b['uuid']!=_0x1c382b[_0x0f94('0x18')]?_0x0f94('0x1d'):_0x0f94('0x1e');}return _0x1c382b;}catch(_0x40ae66){breakingLicense[_0x0f94('0xc')]=_0x29774d['data1'];breakingLicense[_0x0f94('0x1f')]=_0x40ae66['message'];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x4f199,_0x5b689f){getLicense()[_0x0f94('0xb')](function(_0x33185a){return db['User']['findAll']({'attributes':[_0x0f94('0x20'),[db['sequelize']['fn'](_0x0f94('0x21'),db[_0x0f94('0x22')]['col']('role')),'count']],'group':_0x0f94('0x20'),'where':{'role':{'$or':['admin',_0x0f94('0x23'),'telephone']}},'raw':!![]})[_0x0f94('0xb')](function(_0x59b177){var _0x440ba5={'user':_0x33185a[_0x0f94('0x24')]||0x0,'telephone':_0x33185a[_0x0f94('0x25')]||0x0};_0x59b177[_0x0f94('0x26')](function(_0x40ff36){var _0xfae59e=_0x40ff36[_0x0f94('0x20')]==='admin'?'user':_0x40ff36[_0x0f94('0x20')];_0x440ba5[_0xfae59e]-=_0x40ff36[_0x0f94('0x27')];if(_0x440ba5[_0xfae59e]<0x0)_0x440ba5[_0xfae59e]=0x0;});_0x4f199(_0x440ba5);return;});})[_0x0f94('0x28')](function(_0x33e8ae){_0x5b689f(_0x33e8ae);});});}function checkUserLimits(_0x4f45a6){return new BPromise(function(_0xcf6dad,_0xe62ff4){getLimits()[_0x0f94('0xb')](function(_0x2c0e0d){var _0x58a93a=_[_0x0f94('0x29')](_['countBy'](_0x4f45a6,_0x0f94('0x20')),[_0x0f94('0x2a'),_0x0f94('0x23'),_0x0f94('0x2b')]);var _0x348de8=(_0x58a93a[_0x0f94('0x2a')]||0x0)+(_0x58a93a['user']||0x0);var _0x5b007c=_0x58a93a['telephone']||0x0;if(_0x348de8>_0x2c0e0d['user'])return _0xe62ff4('License\x20limit\x20reached\x20for\x20users');if(_0x5b007c>_0x2c0e0d[_0x0f94('0x2b')])return _0xe62ff4(_0x0f94('0x2c'));return _0xcf6dad();})[_0x0f94('0x28')](function(_0x5c7564){_0xe62ff4(_0x5c7564);});});}module[_0x0f94('0x2d')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file