Different team slots config value for premium users

This commit is contained in:
yflory 2023-11-10 16:52:50 +01:00
parent dab8acb4af
commit e33443235d
4 changed files with 22 additions and 9 deletions

View File

@ -270,6 +270,10 @@ define(function() {
// You can change the value here.
// AppConfig.maxOwnedTeams = 5;
// Same settings but for premium users (users with a custom limit included)
// AppConfig.maxPremiumTeamsSlots = 10;
// AppConfig.maxPremiumTeamsOwned = 10;
// The userlist displayed in collaborative documents is stored alongside the document data.
// Everytime someone with edit rights joins a document or modify their user data (display
// name, avatar, color, etc.), they update the "userlist" part of the document. When too many

View File

@ -18,6 +18,8 @@ define(['/customize/application_config.js'], function (AppConfig) {
deprecatedKey: 'deprecated',
MAX_TEAMS_SLOTS: AppConfig.maxTeamsSlots || 5,
MAX_TEAMS_OWNED: AppConfig.maxOwnedTeams || 5,
MAX_PREMIUM_TEAMS_SLOTS: Math.max(AppConfig.maxTeamsSlots || 0, AppConfig.maxPremiumTeamsSlots || 0) || 5,
MAX_PREMIUM_TEAMS_OWNED: Math.max(AppConfig.maxTeamsOwned || 0, AppConfig.maxPremiumTeamsOwned || 0) || 5,
// Apps
criticalApps: ['profile', 'settings', 'debug', 'admin', 'support', 'notifications', 'calendar'],
earlyAccessApps: ['doc', 'presentation']

View File

@ -3599,9 +3599,9 @@ define([
});
};
var MAX_TEAMS_SLOTS = Constants.MAX_TEAMS_SLOTS;
var todo = function (yes) {
var priv = common.getMetadataMgr().getPrivateData();
var MAX_TEAMS_SLOTS = priv.plan ? Constants.MAX_PREMIUM_TEAMS_SLOTS : Constants.MAX_TEAMS_SLOTS;
var numberOfTeams = Object.keys(priv.teams || {}).length;
if (yes) {
if (numberOfTeams >= MAX_TEAMS_SLOTS) {

View File

@ -393,7 +393,6 @@ define([
]);
});
var MAX_TEAMS_SLOTS = Constants.MAX_TEAMS_SLOTS;
var openTeam = function (common, id, team) {
var sframeChan = common.getSframeChannel();
APP.module.execCommand('SUBSCRIBE', id, function () {
@ -421,14 +420,18 @@ define([
});
});
};
var canCreateTeams = function (teams) {
var canCreateTeams = function (common, teams) {
var owned = Object.keys(teams || {}).filter(function (id) {
return teams[id].owner;
}).length;
return Constants.MAX_TEAMS_OWNED - owned;
var priv = common.getMetadataMgr().getPrivateData();
var MAX_TEAMS_OWNED = priv.plan ? Constants.MAX_PREMIUM_TEAMS_OWNED : Constants.MAX_TEAMS_OWNED;
return MAX_TEAMS_OWNED - owned;
};
var refreshList = function (common, cb) {
var content = [];
var priv = common.getMetadataMgr().getPrivateData();
var MAX_TEAMS_SLOTS = priv.plan ? Constants.MAX_PREMIUM_TEAMS_SLOTS : Constants.MAX_TEAMS_SLOTS;
APP.module.execCommand('LIST_TEAMS', null, function (obj) {
if (!obj) { return; }
if (obj.error === "OFFLINE") { return UI.alert(Messages.driveOfflineError); }
@ -436,7 +439,7 @@ define([
var list = [];
var keys = Object.keys(obj).slice(0,MAX_TEAMS_SLOTS);
var slots = '('+Math.min(keys.length, MAX_TEAMS_SLOTS)+'/'+MAX_TEAMS_SLOTS+')';
var createSlots = canCreateTeams(obj);
var createSlots = canCreateTeams(common, obj);
for (var i = keys.length; i < MAX_TEAMS_SLOTS; i++) {
obj[i] = {
empty: true
@ -513,9 +516,12 @@ define([
var privateData = metadataMgr.getPrivateData();
var content = [];
var MAX_TEAMS_OWNED = privateData.plan ? Constants.MAX_PREMIUM_TEAMS_OWNED : Constants.MAX_TEAMS_OWNED;
var MAX_TEAMS_SLOTS = privateData.plan ? Constants.MAX_PREMIUM_TEAMS_SLOTS : Constants.MAX_TEAMS_SLOTS;
var isOwner = Object.keys(privateData.teams || {}).filter(function (id) {
return privateData.teams[id].owner;
}).length >= Constants.MAX_TEAMS_OWNED && !privateData.devMode;
}).length >= MAX_TEAMS_OWNED && !privateData.devMode;
var getWarningBox = function () {
return h('div.alert.alert-warning', {
@ -523,7 +529,7 @@ define([
}, Messages._getKey('team_maxTeams', [MAX_TEAMS_SLOTS]));
};
if (Object.keys(privateData.teams || {}).length >= Constants.MAX_TEAMS_SLOTS || isOwner) {
if (Object.keys(privateData.teams || {}).length >= MAX_TEAMS_SLOTS || isOwner) {
content.push(getWarningBox());
return void cb(content);
}
@ -1252,12 +1258,13 @@ define([
var password = hashData.password;
var seeds = InviteInner.deriveSeeds(hashData.key);
var sframeChan = common.getSframeChannel();
var MAX_TEAMS_SLOTS = privateData.plan ? Constants.MAX_PREMIUM_TEAMS_SLOTS : Constants.MAX_TEAMS_SLOTS;
if (Object.keys(privateData.teams || {}).length >= Constants.MAX_TEAMS_SLOTS) {
if (Object.keys(privateData.teams || {}).length >= MAX_TEAMS_SLOTS) {
return void cb([
h('div.alert.alert-danger', {
role: 'alert'
}, Messages._getKey('team_maxTeams', [Constants.MAX_TEAMS_SLOTS]))
}, Messages._getKey('team_maxTeams', [MAX_TEAMS_SLOTS]))
]);
}