From d7f7f7922fd20dfc29c7f44519d546749fd2ff02 Mon Sep 17 00:00:00 2001 From: Arjun Komath Date: Sun, 26 Oct 2025 08:45:04 +1100 Subject: [PATCH 1/2] Try migration status check --- .github/workflows/migrate-tenants.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/migrate-tenants.yml b/.github/workflows/migrate-tenants.yml index 81d09d5..0e2ea68 100644 --- a/.github/workflows/migrate-tenants.yml +++ b/.github/workflows/migrate-tenants.yml @@ -70,3 +70,21 @@ jobs: DATABASE_URL: ${{ secrets.DATABASE_URL }} DATABASE_SSL: ${{ secrets.DATABASE_SSL }} run: bun run migrate:tenants + + migration-status: + name: Migration Status + runs-on: ubuntu-latest + needs: [migrate-prod] + environment: prod + if: (github.event_name == 'push' && github.ref == 'refs/heads/release') || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'prod') + + steps: + - name: Check migration status + run: | + if [[ "${{ needs.migrate-prod.result }}" == "success" ]] || [[ "${{ needs.migrate-prod.result }}" == "skipped" ]]; then + echo "Migrations completed successfully or were skipped" + exit 0 + else + echo "Migrations failed" + exit 1 + fi From 539322dd5eceb185196ecfd64fa67c36cef33b95 Mon Sep 17 00:00:00 2001 From: Arjun Komath Date: Sun, 26 Oct 2025 08:50:53 +1100 Subject: [PATCH 2/2] Add resend inbound webhook --- .github/workflows/migrate-tenants.yml | 17 ----------- app/(api)/api/webhook/email/inbound/route.ts | 31 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 app/(api)/api/webhook/email/inbound/route.ts diff --git a/.github/workflows/migrate-tenants.yml b/.github/workflows/migrate-tenants.yml index 0e2ea68..a4c298f 100644 --- a/.github/workflows/migrate-tenants.yml +++ b/.github/workflows/migrate-tenants.yml @@ -71,20 +71,3 @@ jobs: DATABASE_SSL: ${{ secrets.DATABASE_SSL }} run: bun run migrate:tenants - migration-status: - name: Migration Status - runs-on: ubuntu-latest - needs: [migrate-prod] - environment: prod - if: (github.event_name == 'push' && github.ref == 'refs/heads/release') || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'prod') - - steps: - - name: Check migration status - run: | - if [[ "${{ needs.migrate-prod.result }}" == "success" ]] || [[ "${{ needs.migrate-prod.result }}" == "skipped" ]]; then - echo "Migrations completed successfully or were skipped" - exit 0 - else - echo "Migrations failed" - exit 1 - fi diff --git a/app/(api)/api/webhook/email/inbound/route.ts b/app/(api)/api/webhook/email/inbound/route.ts new file mode 100644 index 0000000..b39243a --- /dev/null +++ b/app/(api)/api/webhook/email/inbound/route.ts @@ -0,0 +1,31 @@ +import type { NextRequest } from "next/server"; +import { NextResponse } from "next/server"; +import { Resend } from "resend"; + +export const POST = async (request: NextRequest) => { + try { + const resend = new Resend(process.env.RESEND_API_KEY); + const payload = await request.text(); + + resend.webhooks.verify({ + payload, + headers: { + id: request.headers.get("svix-id")!, + timestamp: request.headers.get("svix-timestamp")!, + signature: request.headers.get("svix-signature")!, + }, + webhookSecret: process.env.RESEND_WEBHOOK_SECRET!, + }); + + const event = await request.json(); + + if (event.type === "email.received") { + console.log("Inbound email received:", event.data); + return NextResponse.json({ received: true }); + } + + return NextResponse.json({}); + } catch { + return new NextResponse("Invalid webhook", { status: 400 }); + } +};