(core) add appsumo endpoints with stub implementations

Summary:
This adds appsumo /token and /notification endpoints, with some
tests.  The stub implementation is sufficient for AppSumo
activation to succeed (when exposed via port forwarding for testing).
It needs fleshing out:

 * Implement upgrade/downgrade/refund and stripe subscription.
 * Implement custom landing page and flow.

Test Plan: added tests

Reviewers: dsagal, georgegevoian

Reviewed By: dsagal

Subscribers: alexmojaki

Differential Revision: https://phab.getgrist.com/D2864
This commit is contained in:
Paul Fitzpatrick
2021-06-17 16:48:46 -04:00
parent ca57b3c099
commit cc04c6481a
7 changed files with 101 additions and 12 deletions

View File

@@ -1138,6 +1138,18 @@ export class FlexServer implements GristServer {
return this.getResourceUrl(doc);
}
/**
* Get a url for a team site.
*/
public async getOrgUrl(orgKey: string|number): Promise<string> {
if (!this.dbManager) { throw new Error('database missing'); }
const org = await this.dbManager.getOrg({
userId: this.dbManager.getPreviewerUserId(),
showAll: true
}, orgKey);
return this.getResourceUrl(this.dbManager.unwrapQueryResult(org));
}
/**
* Get a url for an organization, workspace, or document.
*/
@@ -1448,7 +1460,7 @@ export class FlexServer implements GristServer {
private _getBilling(): IBilling {
if (!this._billing) {
if (!this.dbManager) { throw new Error("need dbManager"); }
this._billing = this.create.Billing(this.dbManager);
this._billing = this.create.Billing(this.dbManager, this);
}
return this._billing;
}

View File

@@ -20,6 +20,7 @@ export interface GristServer {
getHomeUrl(req: express.Request, relPath?: string): string;
getHomeUrlByDocId(docId: string, relPath?: string): Promise<string>;
getDocUrl(docId: string): Promise<string>;
getOrgUrl(orgKey: string|number): Promise<string>;
getResourceUrl(resource: Organization|Workspace|Document): Promise<string>;
getGristConfig(): GristLoadConfig;
getPermitStore(): IPermitStore;

View File

@@ -17,7 +17,7 @@ import { PluginManager } from 'app/server/lib/PluginManager';
export interface ICreate {
LoginSession(comm: Comm, sid: string, domain: string, scopeSession: ScopedSession,
instanceManager: IInstanceManager|null): ILoginSession;
Billing(dbManager: HomeDBManager): IBilling;
Billing(dbManager: HomeDBManager, gristConfig: GristServer): IBilling;
Notifier(dbManager: HomeDBManager, gristConfig: GristServer): INotifier;
Shell(): IShell|undefined;