summaryrefslogtreecommitdiffhomepage
path: root/packages/console/app/src/routes/api
diff options
context:
space:
mode:
authorRyan Vogel <[email protected]>2026-03-17 22:43:43 -0400
committerGitHub <[email protected]>2026-03-17 22:43:43 -0400
commita849a17e9329f0b4b0dbb85abf1366b51f935f8c (patch)
tree2f2958b68a99962f193ea0410bec27d70d0d25ad /packages/console/app/src/routes/api
parent0292f1b5596db954e3811f91a9fafcfad650ead1 (diff)
downloadopencode-a849a17e9329f0b4b0dbb85abf1366b51f935f8c.tar.gz
opencode-a849a17e9329f0b4b0dbb85abf1366b51f935f8c.zip
feat(enterprise): contact form now pushes to salesforce 🙄 (#17964)
Co-authored-by: slickstef11 <[email protected]> Co-authored-by: Frank <[email protected]>
Diffstat (limited to 'packages/console/app/src/routes/api')
-rw-r--r--packages/console/app/src/routes/api/enterprise.ts51
1 files changed, 39 insertions, 12 deletions
diff --git a/packages/console/app/src/routes/api/enterprise.ts b/packages/console/app/src/routes/api/enterprise.ts
index 27e2dc493..1bc4d0eb2 100644
--- a/packages/console/app/src/routes/api/enterprise.ts
+++ b/packages/console/app/src/routes/api/enterprise.ts
@@ -2,11 +2,15 @@ import type { APIEvent } from "@solidjs/start/server"
import { AWS } from "@opencode-ai/console-core/aws.js"
import { i18n } from "~/i18n"
import { localeFromRequest } from "~/lib/language"
+import { createLead } from "~/lib/salesforce"
interface EnterpriseFormData {
name: string
role: string
+ company?: string
email: string
+ phone?: string
+ alias?: string
message: string
}
@@ -14,33 +18,56 @@ export async function POST(event: APIEvent) {
const dict = i18n(localeFromRequest(event.request))
try {
const body = (await event.request.json()) as EnterpriseFormData
+ const trap = typeof body.alias === "string" ? body.alias.trim() : ""
+
+ if (trap) {
+ return Response.json({ success: true, message: dict["enterprise.form.success.submitted"] }, { status: 200 })
+ }
- // Validate required fields
if (!body.name || !body.role || !body.email || !body.message) {
return Response.json({ error: dict["enterprise.form.error.allFieldsRequired"] }, { status: 400 })
}
- // Validate email format
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
if (!emailRegex.test(body.email)) {
return Response.json({ error: dict["enterprise.form.error.invalidEmailFormat"] }, { status: 400 })
}
- // Create email content
const emailContent = `
${body.message}<br><br>
--<br>
${body.name}<br>
${body.role}<br>
-${body.email}`.trim()
-
- // Send email using AWS SES
- await AWS.sendEmail({
- subject: `Enterprise Inquiry from ${body.name}`,
- body: emailContent,
- replyTo: body.email,
- })
+${body.company ? `${body.company}<br>` : ""}${body.email}<br>
+${body.phone ? `${body.phone}<br>` : ""}`.trim()
+
+ const [lead, mail] = await Promise.all([
+ createLead({
+ name: body.name,
+ role: body.role,
+ company: body.company,
+ email: body.email,
+ phone: body.phone,
+ message: body.message,
+ }),
+ AWS.sendEmail({
+ subject: `Enterprise Inquiry from ${body.name}`,
+ body: emailContent,
+ replyTo: body.email,
+ }).then(
+ () => true,
+ (err) => {
+ console.error("Failed to send enterprise email:", err)
+ return false
+ },
+ ),
+ ])
+
+ if (!lead && !mail) {
+ console.error("Enterprise inquiry delivery failed", { email: body.email })
+ return Response.json({ error: dict["enterprise.form.error.internalServer"] }, { status: 500 })
+ }
return Response.json({ success: true, message: dict["enterprise.form.success.submitted"] }, { status: 200 })
} catch (error) {