mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[bug] Move convertToFileParams, convertToServerParams from replaceable license.js
This commit is contained in:
@ -33,7 +33,6 @@
|
||||
'use strict';
|
||||
|
||||
const constants = require('./constants');
|
||||
const commonDefines = require('./commonDefines');
|
||||
|
||||
const buildDate = '6/29/2016';
|
||||
const oBuildDate = new Date(buildDate);
|
||||
@ -57,48 +56,5 @@ exports.readLicense = function*() {
|
||||
endDate: null
|
||||
};
|
||||
};
|
||||
exports.convertToFileParams = function(licenseInfo) {
|
||||
// todo
|
||||
// {
|
||||
// user_quota = 0;
|
||||
// portal_count = 0;
|
||||
// process = 2;
|
||||
// ssbranding = false;
|
||||
// whiteLabel = false;
|
||||
// }
|
||||
let license = {};
|
||||
license.end_date = licenseInfo.endDate && licenseInfo.endDate.toJSON();
|
||||
license.trial = constants.LICENSE_MODE.Trial === licenseInfo.mode;
|
||||
license.developer = constants.LICENSE_MODE.Developer === licenseInfo.mode;
|
||||
switch (licenseInfo.mode) {
|
||||
case constants.LICENSE_MODE.Developer:
|
||||
license.mode = 'developer';
|
||||
break;
|
||||
case constants.LICENSE_MODE.Trial:
|
||||
license.mode = 'trial';
|
||||
break;
|
||||
default:
|
||||
license.mode = '';
|
||||
break;
|
||||
}
|
||||
license.light = licenseInfo.light;
|
||||
license.branding = licenseInfo.branding;
|
||||
license.customization = licenseInfo.customization;
|
||||
license.plugins = licenseInfo.plugins;
|
||||
license.connections = licenseInfo.connections;
|
||||
license.users_count = licenseInfo.usersCount;
|
||||
license.users_expire = licenseInfo.usersExpire / constants.LICENSE_EXPIRE_USERS_ONE_DAY;
|
||||
return license;
|
||||
};
|
||||
exports.convertToServerParams = function(licenseInfo) {
|
||||
let license = {};
|
||||
license.workersCount = licenseInfo.count;
|
||||
license.resultType = licenseInfo.type;
|
||||
license.packageType = licenseInfo.packageType;
|
||||
license.buildDate = licenseInfo.buildDate && licenseInfo.buildDate.toJSON();
|
||||
license.buildVersion = commonDefines.buildVersion;
|
||||
license.buildNumber = commonDefines.buildNumber;
|
||||
return license;
|
||||
};
|
||||
|
||||
exports.packageType = constants.PACKAGE_TYPE_OS;
|
||||
|
||||
@ -54,6 +54,7 @@ const jwt = require('jsonwebtoken');
|
||||
const NodeCache = require( "node-cache" );
|
||||
const ms = require('ms');
|
||||
const constants = require('./constants');
|
||||
const commonDefines = require('./commondefines');
|
||||
const logger = require('./logger');
|
||||
const forwarded = require('forwarded');
|
||||
const mime = require('mime');
|
||||
@ -893,3 +894,46 @@ exports.decryptPassword = co.wrap(function* (password) {
|
||||
exports.getDateTimeTicks = function(date) {
|
||||
return BigInt(date.getTime() * 10000) + 621355968000000000n;
|
||||
};
|
||||
exports.convertLicenseInfoToFileParams = function(licenseInfo) {
|
||||
// todo
|
||||
// {
|
||||
// user_quota = 0;
|
||||
// portal_count = 0;
|
||||
// process = 2;
|
||||
// ssbranding = false;
|
||||
// whiteLabel = false;
|
||||
// }
|
||||
let license = {};
|
||||
license.end_date = licenseInfo.endDate && licenseInfo.endDate.toJSON();
|
||||
license.trial = constants.LICENSE_MODE.Trial === licenseInfo.mode;
|
||||
license.developer = constants.LICENSE_MODE.Developer === licenseInfo.mode;
|
||||
switch (licenseInfo.mode) {
|
||||
case constants.LICENSE_MODE.Developer:
|
||||
license.mode = 'developer';
|
||||
break;
|
||||
case constants.LICENSE_MODE.Trial:
|
||||
license.mode = 'trial';
|
||||
break;
|
||||
default:
|
||||
license.mode = '';
|
||||
break;
|
||||
}
|
||||
license.light = licenseInfo.light;
|
||||
license.branding = licenseInfo.branding;
|
||||
license.customization = licenseInfo.customization;
|
||||
license.plugins = licenseInfo.plugins;
|
||||
license.connections = licenseInfo.connections;
|
||||
license.users_count = licenseInfo.usersCount;
|
||||
license.users_expire = licenseInfo.usersExpire / constants.LICENSE_EXPIRE_USERS_ONE_DAY;
|
||||
return license;
|
||||
};
|
||||
exports.convertLicenseInfoToServerParams = function(licenseInfo) {
|
||||
let license = {};
|
||||
license.workersCount = licenseInfo.count;
|
||||
license.resultType = licenseInfo.type;
|
||||
license.packageType = licenseInfo.packageType;
|
||||
license.buildDate = licenseInfo.buildDate && licenseInfo.buildDate.toJSON();
|
||||
license.buildVersion = commonDefines.buildVersion;
|
||||
license.buildNumber = commonDefines.buildNumber;
|
||||
return license;
|
||||
};
|
||||
|
||||
@ -3267,7 +3267,7 @@ exports.licenseInfo = function(req, res) {
|
||||
});
|
||||
};
|
||||
let commandLicense = co.wrap(function*() {
|
||||
let res = {license: license.convertToFileParams(licenseInfo), server: license.convertToServerParams(licenseInfo), quota: {}};
|
||||
let res = {license: utils.convertLicenseInfoToFileParams(licenseInfo), server: utils.convertLicenseInfoToServerParams(licenseInfo), quota: {}};
|
||||
const nowUTC = getLicenseNowUtc();
|
||||
let scores = [];
|
||||
let execRes = yield editorData.getPresenceUniqueUser(nowUTC, scores);
|
||||
|
||||
Reference in New Issue
Block a user