Built motion from commit f3da74b7.|2.5.36
[motion2.git] / server / config / license / util.js
index ce4e32d..12774c9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb8f6=['data2','split','decryptString','format','%s:%s:%s','parse','demo','uuid','gray','deadline','machineUuid','disabled','message','findAll','role','COUNT','sequelize','col','count','admin','user','telephone','telephones','forEach','pick','countBy','License\x20limit\x20reached\x20for\x20users','License\x20limit\x20reached\x20for\x20telephones','exports','util','moment','bluebird','./hardware','../../components/encryptor','../../mysqldb','2027-01-01T00:00:00.000Z','Demo\x20license','getUuid','Breaking\x20license','find','defaults','then','catch','data1','license','isEmpty'];(function(_0xca212f,_0x1e1152){var _0x624483=function(_0x6b36e1){while(--_0x6b36e1){_0xca212f['push'](_0xca212f['shift']());}};_0x624483(++_0x1e1152);}(_0xb8f6,0xa7));var _0x6b8f=function(_0x5bd426,_0x4878e5){_0x5bd426=_0x5bd426-0x0;var _0x23a7eb=_0xb8f6[_0x5bd426];return _0x23a7eb;};'use strict';var util=require(_0x6b8f('0x0'));var _=require('lodash');var moment=require(_0x6b8f('0x1'));var BPromise=require(_0x6b8f('0x2'));var hardware=require(_0x6b8f('0x3'));var encryptor=require(_0x6b8f('0x4'));var db=require(_0x6b8f('0x5'))['db'];const demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x6b8f('0x6'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':_0x6b8f('0x7'),'machineUuid':hardware[_0x6b8f('0x8')](),'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':_0x6b8f('0x9'),'machineUuid':hardware[_0x6b8f('0x8')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x353151){return new BPromise(function(_0x5b4aa6,_0x10514c){return db['License'][_0x6b8f('0xa')](_[_0x6b8f('0xb')](_0x353151,{'raw':!![],'where':{'id':0x1}}))[_0x6b8f('0xc')](function(_0x21f04a){return checkLicense(_0x21f04a,null);})['then'](function(_0x383f18){_0x5b4aa6(_0x383f18);return;})[_0x6b8f('0xd')](function(_0x729c84){_0x10514c(_0x729c84);});});}function checkLicense(_0x151d0d,_0x493bbf){if(!_0x151d0d){demoLicense['uuid']=_0x151d0d[_0x6b8f('0xe')];return demoLicense;}try{var _0x142725=_0x493bbf||_0x151d0d[_0x6b8f('0xf')];if(_[_0x6b8f('0x10')](_0x142725)){throw new Error('License\x20key\x20value\x20not\x20found');}var _0x26169f=_0x151d0d[_0x6b8f('0xe')];var _0x56cc11=_0x151d0d[_0x6b8f('0x11')];var _0x2c248f=_0x26169f[_0x6b8f('0x12')]('-')[0x4];var _0x23c79f=_0x26169f[_0x6b8f('0x12')]('-')[0x0];var _0x40b383=encryptor[_0x6b8f('0x13')](_0x142725,util[_0x6b8f('0x14')](_0x6b8f('0x15'),_0x2c248f,_0x26169f,_0x23c79f));var _0x37531a=JSON[_0x6b8f('0x16')](_0x40b383);_0x37531a[_0x6b8f('0x17')]=![];_0x37531a[_0x6b8f('0x18')]=_0x26169f;_0x37531a['machineUuid']=hardware[_0x6b8f('0x8')]();if(_0x56cc11){var _0x3b1aae=encryptor[_0x6b8f('0x13')](_0x56cc11);_0x37531a[_0x6b8f('0x19')]=_0x3b1aae;_0x37531a[_0x6b8f('0x1a')]=moment(_0x3b1aae)['add'](0x7,'days')[_0x6b8f('0x14')]();_0x37531a['grayReason']=_0x37531a[_0x6b8f('0x18')]!=_0x37531a[_0x6b8f('0x1b')]?'changed':_0x6b8f('0x1c');}return _0x37531a;}catch(_0x55e7e2){breakingLicense[_0x6b8f('0x18')]=_0x151d0d[_0x6b8f('0xe')];breakingLicense[_0x6b8f('0x1d')]=_0x55e7e2['message'];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x372d76,_0x29e288){getLicense()[_0x6b8f('0xc')](function(_0x311ef2){return db['User'][_0x6b8f('0x1e')]({'attributes':[_0x6b8f('0x1f'),[db['sequelize']['fn'](_0x6b8f('0x20'),db[_0x6b8f('0x21')][_0x6b8f('0x22')](_0x6b8f('0x1f'))),_0x6b8f('0x23')]],'group':_0x6b8f('0x1f'),'where':{'role':{'$or':[_0x6b8f('0x24'),_0x6b8f('0x25'),_0x6b8f('0x26')]}},'raw':!![]})['then'](function(_0x4fb0ec){var _0x1895ce={'user':_0x311ef2['users']||0x0,'telephone':_0x311ef2[_0x6b8f('0x27')]||0x0};_0x4fb0ec[_0x6b8f('0x28')](function(_0x3ac3d6){var _0x26a55d=_0x3ac3d6[_0x6b8f('0x1f')]==='admin'?_0x6b8f('0x25'):_0x3ac3d6['role'];_0x1895ce[_0x26a55d]-=_0x3ac3d6[_0x6b8f('0x23')];if(_0x1895ce[_0x26a55d]<0x0)_0x1895ce[_0x26a55d]=0x0;});_0x372d76(_0x1895ce);return;});})[_0x6b8f('0xd')](function(_0x20f9e6){_0x29e288(_0x20f9e6);});});}function checkUserLimits(_0xe54bc0){return new BPromise(function(_0x4e8564,_0x2d2d00){getLimits()[_0x6b8f('0xc')](function(_0x10a4e3){var _0x5c0d6f=_[_0x6b8f('0x29')](_[_0x6b8f('0x2a')](_0xe54bc0,_0x6b8f('0x1f')),[_0x6b8f('0x24'),'user',_0x6b8f('0x26')]);var _0x493c18=(_0x5c0d6f['admin']||0x0)+(_0x5c0d6f[_0x6b8f('0x25')]||0x0);var _0x8db74=_0x5c0d6f['telephone']||0x0;if(_0x493c18>_0x10a4e3[_0x6b8f('0x25')])return _0x2d2d00(_0x6b8f('0x2b'));if(_0x8db74>_0x10a4e3[_0x6b8f('0x26')])return _0x2d2d00(_0x6b8f('0x2c'));return _0x4e8564();})[_0x6b8f('0xd')](function(_0x14941d){_0x2d2d00(_0x14941d);});});}module[_0x6b8f('0x2d')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file
+var _0x6466=['data1','split','decryptString','format','parse','demo','machineUuid','gray','deadline','add','days','grayReason','disabled','message','User','findAll','role','sequelize','COUNT','col','count','admin','user','users','telephones','forEach','pick','countBy','telephone','License\x20limit\x20reached\x20for\x20users','License\x20limit\x20reached\x20for\x20telephones','exports','util','./hardware','../../components/encryptor','../../mysqldb','2027-01-01T00:00:00.000Z','getUuid','Breaking\x20license','License','find','defaults','then','catch','license','isEmpty','License\x20key\x20value\x20not\x20found'];(function(_0x1db651,_0x59a68e){var _0x3d547c=function(_0x9b4313){while(--_0x9b4313){_0x1db651['push'](_0x1db651['shift']());}};_0x3d547c(++_0x59a68e);}(_0x6466,0xad));var _0x6646=function(_0x5287df,_0x46c2b6){_0x5287df=_0x5287df-0x0;var _0x187792=_0x6466[_0x5287df];return _0x187792;};'use strict';var util=require(_0x6646('0x0'));var _=require('lodash');var moment=require('moment');var BPromise=require('bluebird');var hardware=require(_0x6646('0x1'));var encryptor=require(_0x6646('0x2'));var db=require(_0x6646('0x3'))['db'];const demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x6646('0x4'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':'Demo\x20license','machineUuid':hardware[_0x6646('0x5')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};const breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x6646('0x4'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x6646('0x6'),'machineUuid':hardware[_0x6646('0x5')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x449aad){return new BPromise(function(_0x324456,_0x11bb28){return db[_0x6646('0x7')][_0x6646('0x8')](_[_0x6646('0x9')](_0x449aad,{'raw':!![],'where':{'id':0x1}}))[_0x6646('0xa')](function(_0x23bd71){return checkLicense(_0x23bd71,null);})['then'](function(_0x72d6f3){_0x324456(_0x72d6f3);return;})[_0x6646('0xb')](function(_0x56af42){_0x11bb28(_0x56af42);});});}function checkLicense(_0x1cc0c1,_0x20a1a5){if(!_0x1cc0c1){demoLicense['uuid']=_0x1cc0c1['data1'];return demoLicense;}try{var _0x196659=_0x20a1a5||_0x1cc0c1[_0x6646('0xc')];if(_[_0x6646('0xd')](_0x196659)){throw new Error(_0x6646('0xe'));}var _0x28c106=_0x1cc0c1[_0x6646('0xf')];var _0x3a34c6=_0x1cc0c1['data2'];var _0x13654b=_0x28c106[_0x6646('0x10')]('-')[0x4];var _0x46831d=_0x28c106['split']('-')[0x0];var _0x2c563f=encryptor[_0x6646('0x11')](_0x196659,util[_0x6646('0x12')]('%s:%s:%s',_0x13654b,_0x28c106,_0x46831d));var _0x437bd1=JSON[_0x6646('0x13')](_0x2c563f);_0x437bd1[_0x6646('0x14')]=![];_0x437bd1['uuid']=_0x28c106;_0x437bd1[_0x6646('0x15')]=hardware[_0x6646('0x5')]();if(_0x3a34c6){var _0x1b1ad6=encryptor[_0x6646('0x11')](_0x3a34c6);_0x437bd1[_0x6646('0x16')]=_0x1b1ad6;_0x437bd1[_0x6646('0x17')]=moment(_0x1b1ad6)[_0x6646('0x18')](0x7,_0x6646('0x19'))[_0x6646('0x12')]();_0x437bd1[_0x6646('0x1a')]=_0x437bd1['uuid']!=_0x437bd1[_0x6646('0x15')]?'changed':_0x6646('0x1b');}return _0x437bd1;}catch(_0x8a491){breakingLicense['uuid']=_0x1cc0c1[_0x6646('0xf')];breakingLicense[_0x6646('0x1c')]=_0x8a491[_0x6646('0x1c')];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x1c09d3,_0x59adad){getLicense()[_0x6646('0xa')](function(_0x3d1ac6){return db[_0x6646('0x1d')][_0x6646('0x1e')]({'attributes':[_0x6646('0x1f'),[db[_0x6646('0x20')]['fn'](_0x6646('0x21'),db[_0x6646('0x20')][_0x6646('0x22')](_0x6646('0x1f'))),_0x6646('0x23')]],'group':_0x6646('0x1f'),'where':{'role':{'$or':[_0x6646('0x24'),_0x6646('0x25'),'telephone']}},'raw':!![]})[_0x6646('0xa')](function(_0x5b1ffe){var _0x41d8dd={'user':_0x3d1ac6[_0x6646('0x26')]||0x0,'telephone':_0x3d1ac6[_0x6646('0x27')]||0x0};_0x5b1ffe[_0x6646('0x28')](function(_0x5c408e){var _0x2a6c87=_0x5c408e['role']===_0x6646('0x24')?_0x6646('0x25'):_0x5c408e[_0x6646('0x1f')];_0x41d8dd[_0x2a6c87]-=_0x5c408e['count'];if(_0x41d8dd[_0x2a6c87]<0x0)_0x41d8dd[_0x2a6c87]=0x0;});_0x1c09d3(_0x41d8dd);return;});})[_0x6646('0xb')](function(_0x978443){_0x59adad(_0x978443);});});}function checkUserLimits(_0x35903e){return new BPromise(function(_0x2801e2,_0x49645d){getLimits()[_0x6646('0xa')](function(_0x4a3d4a){var _0x4bf935=_[_0x6646('0x29')](_[_0x6646('0x2a')](_0x35903e,_0x6646('0x1f')),[_0x6646('0x24'),_0x6646('0x25'),_0x6646('0x2b')]);var _0x220275=(_0x4bf935[_0x6646('0x24')]||0x0)+(_0x4bf935[_0x6646('0x25')]||0x0);var _0x59fcc3=_0x4bf935['telephone']||0x0;if(_0x220275>_0x4a3d4a[_0x6646('0x25')])return _0x49645d(_0x6646('0x2c'));if(_0x59fcc3>_0x4a3d4a[_0x6646('0x2b')])return _0x49645d(_0x6646('0x2d'));return _0x2801e2();})['catch'](function(_0x34af90){_0x49645d(_0x34af90);});});}module[_0x6646('0x2e')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file