Skip to content

Commit

Permalink
[bug] Move convertToFileParams, convertToServerParams from replaceabl…
Browse files Browse the repository at this point in the history
…e license.js

# Conflicts:
#	Common/sources/utils.js
  • Loading branch information
konovalovsergey committed May 24, 2021
1 parent ae9c548 commit 864752b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 45 deletions.
44 changes: 0 additions & 44 deletions Common/sources/license.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
'use strict';

const constants = require('./constants');
const commonDefines = require('./commonDefines');

const buildDate = '6/29/2016';
const oBuildDate = new Date(buildDate);
Expand All @@ -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;
45 changes: 45 additions & 0 deletions Common/sources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -868,3 +869,47 @@ exports.decryptPassword = co.wrap(function* (password) {
const { data: decrypted } = yield openpgp.decrypt(params);
return decrypted;
});

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;
};
2 changes: 1 addition & 1 deletion DocService/sources/DocsCoServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3225,7 +3225,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);
Expand Down

0 comments on commit 864752b

Please sign in to comment.