Built motion from commit 1fd437e9.|2.6.19
[motion2.git] / server / config / license / util.js
index 62c9500..bee7ea1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc075=['parse','demo','gray','deadline','machineUuid','changed','disabled','User','role','COUNT','sequelize','admin','user','telephone','users','forEach','count','catch','countBy','License\x20limit\x20reached\x20for\x20users','License\x20limit\x20reached\x20for\x20telephones','exports','util','lodash','moment','bluebird','../../components/encryptor','../../mysqldb','2027-01-01T00:00:00.000Z','Demo\x20license','getUuid','Breaking\x20license','License','find','defaults','then','uuid','data1','license','License\x20key\x20value\x20not\x20found','data2','split','decryptString','%s:%s:%s'];(function(_0x27beea,_0x3bc9f4){var _0x122645=function(_0x2c848){while(--_0x2c848){_0x27beea['push'](_0x27beea['shift']());}};_0x122645(++_0x3bc9f4);}(_0xc075,0x6e));var _0x5c07=function(_0x167499,_0x427f89){_0x167499=_0x167499-0x0;var _0x5d56f8=_0xc075[_0x167499];return _0x5d56f8;};'use strict';var util=require(_0x5c07('0x0'));var _=require(_0x5c07('0x1'));var moment=require(_0x5c07('0x2'));var BPromise=require(_0x5c07('0x3'));var hardware=require('./hardware');var encryptor=require(_0x5c07('0x4'));var db=require(_0x5c07('0x5'))['db'];const demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x5c07('0x6'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':_0x5c07('0x7'),'machineUuid':hardware[_0x5c07('0x8')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};const breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x5c07('0x6'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x5c07('0x9'),'machineUuid':hardware[_0x5c07('0x8')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x55d698){return new BPromise(function(_0xc52862,_0x59d07c){return db[_0x5c07('0xa')][_0x5c07('0xb')](_[_0x5c07('0xc')](_0x55d698,{'raw':!![],'where':{'id':0x1}}))[_0x5c07('0xd')](function(_0x9baaf5){return checkLicense(_0x9baaf5,null);})[_0x5c07('0xd')](function(_0x1119ba){_0xc52862(_0x1119ba);return;})['catch'](function(_0x5e7ef2){_0x59d07c(_0x5e7ef2);});});}function checkLicense(_0x46a5a9,_0x46fa40){if(!_0x46a5a9){demoLicense[_0x5c07('0xe')]=_0x46a5a9[_0x5c07('0xf')];return demoLicense;}try{var _0x2cafdb=_0x46fa40||_0x46a5a9[_0x5c07('0x10')];if(_['isEmpty'](_0x2cafdb)){throw new Error(_0x5c07('0x11'));}var _0x15a00e=_0x46a5a9['data1'];var _0x3209c6=_0x46a5a9[_0x5c07('0x12')];var _0x2ea354=_0x15a00e[_0x5c07('0x13')]('-')[0x4];var _0x53c9c6=_0x15a00e[_0x5c07('0x13')]('-')[0x0];var _0xf921b8=encryptor[_0x5c07('0x14')](_0x2cafdb,util['format'](_0x5c07('0x15'),_0x2ea354,_0x15a00e,_0x53c9c6));var _0x277392=JSON[_0x5c07('0x16')](_0xf921b8);_0x277392[_0x5c07('0x17')]=![];_0x277392[_0x5c07('0xe')]=_0x15a00e;_0x277392['machineUuid']=hardware[_0x5c07('0x8')]();if(_0x3209c6){var _0x36c926=encryptor[_0x5c07('0x14')](_0x3209c6);_0x277392[_0x5c07('0x18')]=_0x36c926;_0x277392[_0x5c07('0x19')]=moment(_0x36c926)['add'](0x7,'days')['format']();_0x277392['grayReason']=_0x277392[_0x5c07('0xe')]!=_0x277392[_0x5c07('0x1a')]?_0x5c07('0x1b'):_0x5c07('0x1c');}return _0x277392;}catch(_0x559e0c){breakingLicense[_0x5c07('0xe')]=_0x46a5a9['data1'];breakingLicense['message']=_0x559e0c['message'];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x41b952,_0x3d443b){getLicense()[_0x5c07('0xd')](function(_0x3fb585){return db[_0x5c07('0x1d')]['findAll']({'attributes':[_0x5c07('0x1e'),[db['sequelize']['fn'](_0x5c07('0x1f'),db[_0x5c07('0x20')]['col']('role')),'count']],'group':_0x5c07('0x1e'),'where':{'role':{'$or':[_0x5c07('0x21'),_0x5c07('0x22'),_0x5c07('0x23')]}},'raw':!![]})[_0x5c07('0xd')](function(_0x5d65d3){var _0x1fad53={'user':_0x3fb585[_0x5c07('0x24')]||0x0,'telephone':_0x3fb585['telephones']||0x0};_0x5d65d3[_0x5c07('0x25')](function(_0x1c0ee1){var _0x985e86=_0x1c0ee1[_0x5c07('0x1e')]===_0x5c07('0x21')?_0x5c07('0x22'):_0x1c0ee1[_0x5c07('0x1e')];_0x1fad53[_0x985e86]-=_0x1c0ee1[_0x5c07('0x26')];if(_0x1fad53[_0x985e86]<0x0)_0x1fad53[_0x985e86]=0x0;});_0x41b952(_0x1fad53);return;});})[_0x5c07('0x27')](function(_0x3a153a){_0x3d443b(_0x3a153a);});});}function checkUserLimits(_0x490a91){return new BPromise(function(_0xff83ad,_0x10de08){getLimits()[_0x5c07('0xd')](function(_0x5de920){var _0x3c0964=_['pick'](_[_0x5c07('0x28')](_0x490a91,_0x5c07('0x1e')),['admin','user',_0x5c07('0x23')]);var _0x1b5ddb=(_0x3c0964[_0x5c07('0x21')]||0x0)+(_0x3c0964[_0x5c07('0x22')]||0x0);var _0x1d60b1=_0x3c0964[_0x5c07('0x23')]||0x0;if(_0x1b5ddb>_0x5de920[_0x5c07('0x22')])return _0x10de08(_0x5c07('0x29'));if(_0x1d60b1>_0x5de920['telephone'])return _0x10de08(_0x5c07('0x2a'));return _0xff83ad();})[_0x5c07('0x27')](function(_0x1dab72){_0x10de08(_0x1dab72);});});}module[_0x5c07('0x2b')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file
+var _0x682b=['sequelize','COUNT','count','admin','user','telephone','users','telephones','forEach','pick','countBy','License\x20limit\x20reached\x20for\x20users','License\x20limit\x20reached\x20for\x20telephones','exports','moment','./hardware','../../components/encryptor','2027-01-01T00:00:00.000Z','getUuid','Breaking\x20license','License','find','defaults','then','catch','uuid','data1','license','isEmpty','License\x20key\x20value\x20not\x20found','data2','split','decryptString','format','%s:%s:%s','demo','gray','deadline','add','days','grayReason','machineUuid','changed','message','findAll','role'];(function(_0xbbebbf,_0x5c4820){var _0x2fba5a=function(_0x3026b4){while(--_0x3026b4){_0xbbebbf['push'](_0xbbebbf['shift']());}};_0x2fba5a(++_0x5c4820);}(_0x682b,0x1da));var _0xb682=function(_0x7e2eb0,_0x17cd58){_0x7e2eb0=_0x7e2eb0-0x0;var _0xd92de4=_0x682b[_0x7e2eb0];return _0xd92de4;};'use strict';var util=require('util');var _=require('lodash');var moment=require(_0xb682('0x0'));var BPromise=require('bluebird');var hardware=require(_0xb682('0x1'));var encryptor=require(_0xb682('0x2'));var db=require('../../mysqldb')['db'];const demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0xb682('0x3'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':'Demo\x20license','machineUuid':hardware[_0xb682('0x4')](),'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':_0xb682('0x5'),'machineUuid':hardware[_0xb682('0x4')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x18b87f){return new BPromise(function(_0x2e622c,_0x24de2f){return db[_0xb682('0x6')][_0xb682('0x7')](_[_0xb682('0x8')](_0x18b87f,{'raw':!![],'where':{'id':0x1}}))[_0xb682('0x9')](function(_0xbf3710){return checkLicense(_0xbf3710,null);})['then'](function(_0x68aac7){_0x2e622c(_0x68aac7);return;})[_0xb682('0xa')](function(_0x1f7cd3){_0x24de2f(_0x1f7cd3);});});}function checkLicense(_0x24f0d4,_0x240a5a){if(!_0x24f0d4){demoLicense[_0xb682('0xb')]=_0x24f0d4[_0xb682('0xc')];return demoLicense;}try{var _0x39858b=_0x240a5a||_0x24f0d4[_0xb682('0xd')];if(_[_0xb682('0xe')](_0x39858b)){throw new Error(_0xb682('0xf'));}var _0x740af=_0x24f0d4[_0xb682('0xc')];var _0x50f655=_0x24f0d4[_0xb682('0x10')];var _0x49e8ec=_0x740af[_0xb682('0x11')]('-')[0x4];var _0x3bb819=_0x740af[_0xb682('0x11')]('-')[0x0];var _0x200ff5=encryptor[_0xb682('0x12')](_0x39858b,util[_0xb682('0x13')](_0xb682('0x14'),_0x49e8ec,_0x740af,_0x3bb819));var _0xf030cf=JSON['parse'](_0x200ff5);_0xf030cf[_0xb682('0x15')]=![];_0xf030cf[_0xb682('0xb')]=_0x740af;_0xf030cf['machineUuid']=hardware['getUuid']();if(_0x50f655){var _0xbb6eca=encryptor[_0xb682('0x12')](_0x50f655);_0xf030cf[_0xb682('0x16')]=_0xbb6eca;_0xf030cf[_0xb682('0x17')]=moment(_0xbb6eca)[_0xb682('0x18')](0x7,_0xb682('0x19'))[_0xb682('0x13')]();_0xf030cf[_0xb682('0x1a')]=_0xf030cf[_0xb682('0xb')]!=_0xf030cf[_0xb682('0x1b')]?_0xb682('0x1c'):'disabled';}return _0xf030cf;}catch(_0x32a0e8){breakingLicense['uuid']=_0x24f0d4[_0xb682('0xc')];breakingLicense[_0xb682('0x1d')]=_0x32a0e8[_0xb682('0x1d')];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x1a05ba,_0x5bf1d0){getLicense()[_0xb682('0x9')](function(_0x1a2391){return db['User'][_0xb682('0x1e')]({'attributes':[_0xb682('0x1f'),[db[_0xb682('0x20')]['fn'](_0xb682('0x21'),db[_0xb682('0x20')]['col']('role')),_0xb682('0x22')]],'group':_0xb682('0x1f'),'where':{'role':{'$or':[_0xb682('0x23'),_0xb682('0x24'),_0xb682('0x25')]}},'raw':!![]})[_0xb682('0x9')](function(_0x113b88){var _0x3575fb={'user':_0x1a2391[_0xb682('0x26')]||0x0,'telephone':_0x1a2391[_0xb682('0x27')]||0x0};_0x113b88[_0xb682('0x28')](function(_0x22f9ae){var _0x1fbba1=_0x22f9ae[_0xb682('0x1f')]===_0xb682('0x23')?_0xb682('0x24'):_0x22f9ae['role'];_0x3575fb[_0x1fbba1]-=_0x22f9ae[_0xb682('0x22')];if(_0x3575fb[_0x1fbba1]<0x0)_0x3575fb[_0x1fbba1]=0x0;});_0x1a05ba(_0x3575fb);return;});})[_0xb682('0xa')](function(_0xff3fd9){_0x5bf1d0(_0xff3fd9);});});}function checkUserLimits(_0x580217){return new BPromise(function(_0x59ea6b,_0x25befa){getLimits()[_0xb682('0x9')](function(_0x4a1748){var _0x14151b=_[_0xb682('0x29')](_[_0xb682('0x2a')](_0x580217,_0xb682('0x1f')),[_0xb682('0x23'),'user',_0xb682('0x25')]);var _0x17a693=(_0x14151b[_0xb682('0x23')]||0x0)+(_0x14151b[_0xb682('0x24')]||0x0);var _0x250867=_0x14151b[_0xb682('0x25')]||0x0;if(_0x17a693>_0x4a1748[_0xb682('0x24')])return _0x25befa(_0xb682('0x2b'));if(_0x250867>_0x4a1748[_0xb682('0x25')])return _0x25befa(_0xb682('0x2c'));return _0x59ea6b();})['catch'](function(_0xa3e308){_0x25befa(_0xa3e308);});});}module[_0xb682('0x2d')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file