A full-featured CRM built with React, shadcn/ui, and Supabase.
code review
ThieryMichel8e3b2c33a903
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.ymlindex 7c5a38b2..678822da 100644--- a/.github/workflows/deploy.yml+++ b/.github/workflows/deploy.yml@@ -109,6 +109,7 @@ jobs:POSTMARK_WEBHOOK_USER: ${{secrets.POSTMARK_WEBHOOK_USER}}POSTMARK_WEBHOOK_PASSWORD: ${{secrets.POSTMARK_WEBHOOK_PASSWORD}}POSTMARK_WEBHOOK_AUTHORIZED_IPS: ${{secrets.POSTMARK_WEBHOOK_AUTHORIZED_IPS}}+ POSTMARK_INBOUND_EMAIL: ${{secrets.VITE_INBOUND_EMAIL}}VITE_GOOGLE_WORKPLACE_DOMAIN: ${{secrets.VITE_GOOGLE_WORKPLACE_DOMAIN}}steps:@@ -152,6 +153,7 @@ jobs:npx supabase secrets set POSTMARK_WEBHOOK_USER=${{ env.POSTMARK_WEBHOOK_USER }}npx supabase secrets set POSTMARK_WEBHOOK_PASSWORD=${{ env.POSTMARK_WEBHOOK_PASSWORD }}npx supabase secrets set POSTMARK_WEBHOOK_AUTHORIZED_IPS=${{ env.POSTMARK_WEBHOOK_AUTHORIZED_IPS }}+ npx supabase secrets set POSTMARK_INBOUND_EMAIL=${{ env.POSTMARK_INBOUND_EMAIL }}- if: ${{ env.IS_SUPABASE_CONFIGURED }}name: 📡 Deploy supabase functionsdiff --git a/supabase/functions/.env b/supabase/functions/.envindex f3045108..ccc025d7 100644--- a/supabase/functions/.env+++ b/supabase/functions/.env@@ -1,11 +1,13 @@POSTMARK_WEBHOOK_USER=testuserPOSTMARK_WEBHOOK_PASSWORD=testpwd+POSTMARK_INBOUND_EMAIL=2aff30e603e54dc3eb556bd9e03ee099@inbound.postmarkapp.com# IPs can be found at https://postmarkapp.com/support/article/800-ips-for-firewalls#webhooks-# 172.18.0.1 and 172.19.0.1 are for local dev only+# 172.18.0.1, 172.19.0.1 and 172.20.0.1 are for local dev only# 192.168.65.1 is for Docker Desktop on MacPOSTMARK_WEBHOOK_AUTHORIZED_IPS=3.134.147.250,50.31.156.6,50.31.156.77,18.217.206.57,172.18.0.1,172.19.0.1,192.168.65.1,172.20.0.1SB_JWT_ISSUER=http://127.0.0.1:54321/auth/v1SB_PUBLISHABLE_KEY=sb_publishable_ACJWlzQHlZjBrEguHvfOxg_3BJgxAaHSB_SECRET_KEY=sb_secret_N7UND0UgjKTVK-Uodkm0Hg_xSvEMPvz+diff --git a/supabase/functions/postmark/index.ts b/supabase/functions/postmark/index.tsindex cd5894c7..b6403f6e 100644--- a/supabase/functions/postmark/index.ts+++ b/supabase/functions/postmark/index.ts@@ -17,6 +17,7 @@ import { supabaseAdmin } from "../_shared/supabaseAdmin.ts";const webhookUser = Deno.env.get("POSTMARK_WEBHOOK_USER");const webhookPassword = Deno.env.get("POSTMARK_WEBHOOK_PASSWORD");+const INBOUND_EMAIL = Deno.env.get("POSTMARK_INBOUND_EMAIL");if (!webhookUser || !webhookPassword) {throw new Error("Missing POSTMARK_WEBHOOK_USER or POSTMARK_WEBHOOK_PASSWORD env variable",@@ -29,10 +30,6 @@ if (!rawAuthorizedIPs) {}Deno.serve(async (req) => {- const allSales = await supabaseAdmin.from("sales").select("email");- const salesEmails =- allSales.data?.map((s: { email: string }) => s.email) ?? [];-let response: Response | undefined;response = checkRequestTypeAndHeaders(req);@@ -55,8 +52,9 @@ Deno.serve(async (req) => {);}- // This env var is only available inside the served function- const INBOUND_EMAIL = process.env.VITE_INBOUND_EMAIL;+ const allSales = await supabaseAdmin.from("sales").select("email");+ const salesEmails =+ allSales.data?.map((s: { email: string }) => s.email) ?? [];// If the email is sent to the inbound email address, and the sender is a known sales email,// then we can try to extract the real recipient email from the body of the email@@ -79,6 +77,13 @@ Deno.serve(async (req) => {Name: "",},];+ } else {+ // Return a 403 to let Postmark know that it's no use to retry this request+ // https://postmarkapp.com/developer/webhooks/inbound-webhook#errors-and-retries+ return new Response(+ `Could not extract recipient email from transferred email body: ${TextBody}`,+ { status: 403 },+ );}TextBody = getForwardedMailContent(TextBody);Subject = stripSubjectForwardingPrefix(Subject);