Try to link email to org when creating for first time

This commit is contained in:
Owen
2026-09-21 16:25:58 -04:00
parent 0c752c9c29
commit 750f267451
5 changed files with 66 additions and 1 deletions
+1
View File
@@ -3,3 +3,4 @@ export * from "./features";
export * from "./limitsService";
export * from "./getOrgTierData";
export * from "./createCustomer";
export * from "./linkEmailOrg";
+6
View File
@@ -0,0 +1,6 @@
export async function linkEmailOrg(
orgId: string,
email: string | null | undefined
): Promise<void> {
return;
}
+1
View File
@@ -13,3 +13,4 @@
export * from "./getOrgTierData";
export * from "./createCustomer";
export * from "./linkEmailOrg";
@@ -0,0 +1,56 @@
/*
* This file is part of a proprietary work.
*
* Copyright (c) 2025-2026 Fossorial, Inc.
* All rights reserved.
*
* This file is licensed under the Fossorial Commercial License.
* You may not use this file except in compliance with the License.
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
*
* This file is not licensed under the AGPLv3.
*/
import logger from "@server/logger";
import privateConfig from "#private/lib/config";
import { build } from "@server/build";
export async function linkEmailOrg(
orgId: string,
email: string | null | undefined
): Promise<void> {
if (build !== "saas") {
return;
}
if (!email) {
return;
}
try {
const response = await fetch(
`${privateConfig.getRawPrivateConfig().server.fossorial_api}/api/v1/license-internal/enterprise/link-email-org`,
{
method: "POST",
headers: {
"api-key":
privateConfig.getRawPrivateConfig().server
.fossorial_api_key!,
"Content-Type": "application/json"
},
body: JSON.stringify({ email, orgId })
}
);
if (!response.ok && response.status !== 404) {
logger.error(
`Fossorial API returned ${response.status} when linking email ${email} to orgId ${orgId}: ${await response.text()}`
);
}
} catch (error) {
logger.error(
`Error notifying Fossorial API of email/org link for orgId ${orgId}:`,
error
);
}
}
+2 -1
View File
@@ -25,7 +25,7 @@ import { fromError } from "zod-validation-error";
import { defaultRoleAllowedActions } from "../role";
import { OpenAPITags, registry } from "@server/openApi";
import { isValidCIDR } from "@server/lib/validators";
import { createCustomer } from "#dynamic/lib/billing";
import { createCustomer, linkEmailOrg } from "#dynamic/lib/billing";
import { usageService } from "@server/lib/billing/usageService";
import { LimitId, limitsService, freeLimitSet } from "@server/lib/billing";
import { build } from "@server/build";
@@ -425,6 +425,7 @@ export async function createOrg(
customerId
); // Only 1 because we are creating the org
}
await linkEmailOrg(orgId, req.user?.email);
}
if (numOrgs) {