Built motion from commit 53172ac8.|2.6.30
[motion2.git] / server / config / license / util.js
index 74187cc..4f53a42 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2646=['util','lodash','bluebird','./hardware','../../components/encryptor','getUuid','2027-01-01T00:00:00.000Z','Breaking\x20license','License','find','defaults','then','catch','uuid','data1','license','License\x20key\x20value\x20not\x20found','split','decryptString','format','parse','demo','machineUuid','gray','add','days','changed','disabled','message','User','findAll','role','col','count','admin','user','telephone','telephones','countBy','License\x20limit\x20reached\x20for\x20users','License\x20limit\x20reached\x20for\x20telephones'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x2646,0x1ec));var _0x6264=function(_0x4e7ae5,_0x407167){_0x4e7ae5=_0x4e7ae5-0x0;var _0x14d181=_0x2646[_0x4e7ae5];return _0x14d181;};'use strict';var util=require(_0x6264('0x0'));var _=require(_0x6264('0x1'));var moment=require('moment');var BPromise=require(_0x6264('0x2'));var hardware=require(_0x6264('0x3'));var encryptor=require(_0x6264('0x4'));var db=require('../../mysqldb')['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':'Demo\x20license','machineUuid':hardware[_0x6264('0x5')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};const breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x6264('0x6'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x6264('0x7'),'machineUuid':hardware[_0x6264('0x5')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0xbf3af7){return new BPromise(function(_0x3c26f5,_0x3606c5){return db[_0x6264('0x8')][_0x6264('0x9')](_[_0x6264('0xa')](_0xbf3af7,{'raw':!![],'where':{'id':0x1}}))['then'](function(_0x3778d7){return checkLicense(_0x3778d7,null);})[_0x6264('0xb')](function(_0x44f40a){_0x3c26f5(_0x44f40a);return;})[_0x6264('0xc')](function(_0xf7321a){_0x3606c5(_0xf7321a);});});}function checkLicense(_0x46e471,_0x5ad6e9){if(!_0x46e471){demoLicense[_0x6264('0xd')]=_0x46e471[_0x6264('0xe')];return demoLicense;}try{var _0x5acb47=_0x5ad6e9||_0x46e471[_0x6264('0xf')];if(_['isEmpty'](_0x5acb47)){throw new Error(_0x6264('0x10'));}var _0x53a617=_0x46e471[_0x6264('0xe')];var _0xb4c13e=_0x46e471['data2'];var _0x576f66=_0x53a617[_0x6264('0x11')]('-')[0x4];var _0x3a8df1=_0x53a617[_0x6264('0x11')]('-')[0x0];var _0x10d3be=encryptor[_0x6264('0x12')](_0x5acb47,util[_0x6264('0x13')]('%s:%s:%s',_0x576f66,_0x53a617,_0x3a8df1));var _0x1c45da=JSON[_0x6264('0x14')](_0x10d3be);_0x1c45da[_0x6264('0x15')]=![];_0x1c45da['uuid']=_0x53a617;_0x1c45da[_0x6264('0x16')]=hardware['getUuid']();if(_0xb4c13e){var _0x5dd0e1=encryptor[_0x6264('0x12')](_0xb4c13e);_0x1c45da[_0x6264('0x17')]=_0x5dd0e1;_0x1c45da['deadline']=moment(_0x5dd0e1)[_0x6264('0x18')](0x7,_0x6264('0x19'))[_0x6264('0x13')]();_0x1c45da['grayReason']=_0x1c45da[_0x6264('0xd')]!=_0x1c45da['machineUuid']?_0x6264('0x1a'):_0x6264('0x1b');}return _0x1c45da;}catch(_0x13ef1a){breakingLicense[_0x6264('0xd')]=_0x46e471[_0x6264('0xe')];breakingLicense[_0x6264('0x1c')]=_0x13ef1a[_0x6264('0x1c')];return breakingLicense;}}function getLimits(){return new BPromise(function(_0xed1d13,_0x43745d){getLicense()[_0x6264('0xb')](function(_0x19604d){return db[_0x6264('0x1d')][_0x6264('0x1e')]({'attributes':[_0x6264('0x1f'),[db['sequelize']['fn']('COUNT',db['sequelize'][_0x6264('0x20')](_0x6264('0x1f'))),_0x6264('0x21')]],'group':_0x6264('0x1f'),'where':{'role':{'$or':[_0x6264('0x22'),_0x6264('0x23'),_0x6264('0x24')]}},'raw':!![]})[_0x6264('0xb')](function(_0x2ec4c5){var _0x5aab22={'user':_0x19604d['users']||0x0,'telephone':_0x19604d[_0x6264('0x25')]||0x0};_0x2ec4c5['forEach'](function(_0x4d7578){var _0x15f905=_0x4d7578[_0x6264('0x1f')]===_0x6264('0x22')?_0x6264('0x23'):_0x4d7578['role'];_0x5aab22[_0x15f905]-=_0x4d7578['count'];if(_0x5aab22[_0x15f905]<0x0)_0x5aab22[_0x15f905]=0x0;});_0xed1d13(_0x5aab22);return;});})[_0x6264('0xc')](function(_0x429e92){_0x43745d(_0x429e92);});});}function checkUserLimits(_0x3a2a5f){return new BPromise(function(_0x38723d,_0x5a34cd){getLimits()[_0x6264('0xb')](function(_0x2e26f2){var _0x4964a0=_['pick'](_[_0x6264('0x26')](_0x3a2a5f,_0x6264('0x1f')),[_0x6264('0x22'),_0x6264('0x23'),_0x6264('0x24')]);var _0x24539f=(_0x4964a0['admin']||0x0)+(_0x4964a0[_0x6264('0x23')]||0x0);var _0x2fa57b=_0x4964a0[_0x6264('0x24')]||0x0;if(_0x24539f>_0x2e26f2[_0x6264('0x23')])return _0x5a34cd(_0x6264('0x27'));if(_0x2fa57b>_0x2e26f2[_0x6264('0x24')])return _0x5a34cd(_0x6264('0x28'));return _0x38723d();})[_0x6264('0xc')](function(_0x465324){_0x5a34cd(_0x465324);});});}module['exports']={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file
+var _0x9c6f=['User','findAll','role','COUNT','col','count','user','telephone','users','admin','countBy','License\x20limit\x20reached\x20for\x20users','License\x20limit\x20reached\x20for\x20telephones','util','lodash','moment','bluebird','./hardware','../../mysqldb','Demo\x20license','getUuid','License','find','defaults','then','catch','data1','license','isEmpty','License\x20key\x20value\x20not\x20found','data2','split','decryptString','format','%s:%s:%s','parse','uuid','machineUuid','gray','deadline','days','grayReason','changed','disabled','message'];(function(_0x3b9838,_0x45b29e){var _0xf29ca1=function(_0x1850ca){while(--_0x1850ca){_0x3b9838['push'](_0x3b9838['shift']());}};_0xf29ca1(++_0x45b29e);}(_0x9c6f,0xc1));var _0xf9c6=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x9c6f[_0x3dd15e];return _0x231fd0;};'use strict';var util=require(_0xf9c6('0x0'));var _=require(_0xf9c6('0x1'));var moment=require(_0xf9c6('0x2'));var BPromise=require(_0xf9c6('0x3'));var hardware=require(_0xf9c6('0x4'));var encryptor=require('../../components/encryptor');var db=require(_0xf9c6('0x5'))['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':_0xf9c6('0x6'),'machineUuid':hardware[_0xf9c6('0x7')](),'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':'Breaking\x20license','machineUuid':hardware[_0xf9c6('0x7')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x343f65){return new BPromise(function(_0x12d5bd,_0x3f2c8c){return db[_0xf9c6('0x8')][_0xf9c6('0x9')](_[_0xf9c6('0xa')](_0x343f65,{'raw':!![],'where':{'id':0x1}}))[_0xf9c6('0xb')](function(_0xed352a){return checkLicense(_0xed352a,null);})['then'](function(_0x16f905){_0x12d5bd(_0x16f905);return;})[_0xf9c6('0xc')](function(_0x1c5f1c){_0x3f2c8c(_0x1c5f1c);});});}function checkLicense(_0x46c734,_0x593642){if(!_0x46c734){demoLicense['uuid']=_0x46c734[_0xf9c6('0xd')];return demoLicense;}try{var _0x54e6e4=_0x593642||_0x46c734[_0xf9c6('0xe')];if(_[_0xf9c6('0xf')](_0x54e6e4)){throw new Error(_0xf9c6('0x10'));}var _0x543906=_0x46c734[_0xf9c6('0xd')];var _0x1c00de=_0x46c734[_0xf9c6('0x11')];var _0x533c59=_0x543906['split']('-')[0x4];var _0x4cfad3=_0x543906[_0xf9c6('0x12')]('-')[0x0];var _0x3f162a=encryptor[_0xf9c6('0x13')](_0x54e6e4,util[_0xf9c6('0x14')](_0xf9c6('0x15'),_0x533c59,_0x543906,_0x4cfad3));var _0x15348a=JSON[_0xf9c6('0x16')](_0x3f162a);_0x15348a['demo']=![];_0x15348a[_0xf9c6('0x17')]=_0x543906;_0x15348a[_0xf9c6('0x18')]=hardware[_0xf9c6('0x7')]();if(_0x1c00de){var _0x3f9b19=encryptor['decryptString'](_0x1c00de);_0x15348a[_0xf9c6('0x19')]=_0x3f9b19;_0x15348a[_0xf9c6('0x1a')]=moment(_0x3f9b19)['add'](0x7,_0xf9c6('0x1b'))[_0xf9c6('0x14')]();_0x15348a[_0xf9c6('0x1c')]=_0x15348a[_0xf9c6('0x17')]!=_0x15348a[_0xf9c6('0x18')]?_0xf9c6('0x1d'):_0xf9c6('0x1e');}return _0x15348a;}catch(_0x218872){breakingLicense[_0xf9c6('0x17')]=_0x46c734[_0xf9c6('0xd')];breakingLicense[_0xf9c6('0x1f')]=_0x218872[_0xf9c6('0x1f')];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x1808b6,_0x1ece55){getLicense()[_0xf9c6('0xb')](function(_0x167dc8){return db[_0xf9c6('0x20')][_0xf9c6('0x21')]({'attributes':[_0xf9c6('0x22'),[db['sequelize']['fn'](_0xf9c6('0x23'),db['sequelize'][_0xf9c6('0x24')](_0xf9c6('0x22'))),_0xf9c6('0x25')]],'group':_0xf9c6('0x22'),'where':{'role':{'$or':['admin',_0xf9c6('0x26'),_0xf9c6('0x27')]}},'raw':!![]})[_0xf9c6('0xb')](function(_0x6d2854){var _0x4f6391={'user':_0x167dc8[_0xf9c6('0x28')]||0x0,'telephone':_0x167dc8['telephones']||0x0};_0x6d2854['forEach'](function(_0xa08043){var _0x3a6af0=_0xa08043[_0xf9c6('0x22')]===_0xf9c6('0x29')?'user':_0xa08043[_0xf9c6('0x22')];_0x4f6391[_0x3a6af0]-=_0xa08043[_0xf9c6('0x25')];if(_0x4f6391[_0x3a6af0]<0x0)_0x4f6391[_0x3a6af0]=0x0;});_0x1808b6(_0x4f6391);return;});})[_0xf9c6('0xc')](function(_0x3a634f){_0x1ece55(_0x3a634f);});});}function checkUserLimits(_0x421c22){return new BPromise(function(_0x4f9b13,_0x5b6699){getLimits()['then'](function(_0x5a1cee){var _0x1ce378=_['pick'](_[_0xf9c6('0x2a')](_0x421c22,_0xf9c6('0x22')),['admin',_0xf9c6('0x26'),_0xf9c6('0x27')]);var _0x2bcc01=(_0x1ce378['admin']||0x0)+(_0x1ce378[_0xf9c6('0x26')]||0x0);var _0x29504c=_0x1ce378[_0xf9c6('0x27')]||0x0;if(_0x2bcc01>_0x5a1cee[_0xf9c6('0x26')])return _0x5b6699(_0xf9c6('0x2b'));if(_0x29504c>_0x5a1cee[_0xf9c6('0x27')])return _0x5b6699(_0xf9c6('0x2c'));return _0x4f9b13();})[_0xf9c6('0xc')](function(_0x18fceb){_0x5b6699(_0x18fceb);});});}module['exports']={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file