(core) add free team site product

Summary:
This adds a Feature object that is an approximation of what we
plan for free team sites. It includes restrictions that are not
yet implemented, and an endpoint for testing.

Test Plan: added a test

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3243
This commit is contained in:
Paul Fitzpatrick
2022-02-02 14:30:50 -05:00
parent 64abfcb0ac
commit 4890a1fe89
4 changed files with 43 additions and 3 deletions

View File

@@ -1077,11 +1077,14 @@ export class HomeDBManager extends EventEmitter {
* @param useNewPlan: by default, the individual billing account associated with the
* user's personal org will be used for all other orgs they create. Set useNewPlan
* to force a distinct non-individual billing account to be used for this org.
* @param planType: if set, controls the type of plan used for the org. Only
* meaningful for team sites currently.
*
*/
public async addOrg(user: User, props: Partial<OrganizationProperties>,
options: { setUserAsOwner: boolean,
useNewPlan: boolean,
planType?: 'free',
externalId?: string,
externalOptions?: ExternalBillingOptions },
transaction?: EntityManager): Promise<QueryResult<number>> {
@@ -1110,10 +1113,11 @@ export class HomeDBManager extends EventEmitter {
let billingAccount;
if (options.useNewPlan) {
const productNames = getDefaultProductNames();
let productName = options.setUserAsOwner ? productNames.personal : productNames.teamInitial;
let productName = options.setUserAsOwner ? productNames.personal :
options.planType === 'free' ? productNames.teamFree : productNames.teamInitial;
// A bit fragile: this is called during creation of support@ user, before
// getSupportUserId() is available, but with setUserAsOwner of true.
if (!options.setUserAsOwner && user.id === this.getSupportUserId()) {
if (!options.setUserAsOwner && user.id === this.getSupportUserId() && options.planType !== 'free') {
// For teams created by support@getgrist.com, set the product to something
// good so payment not needed. This is useful for testing.
productName = productNames.team;