Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

Feat(mailing): Add support for multiple recipients and fix some typos in mails

Jonathan ARNAULTb2b634bc8b04
diff --git a/public/auth-callback.html b/public/auth-callback.html
index ab2d5f06..43bb27dc 100644
--- a/public/auth-callback.html
+++ b/public/auth-callback.html
@@ -131,7 +131,7 @@
function interceptAuthCallback() {
const hash = window.location.hash;
const {access_token, refresh_token, type} = getUrlParams();
- window.location.href = `../#/auth-callback?access_token=${access_token}&refresh_token=${refresh_token}&type=${type}`;
+ window.location.href = `./#/auth-callback?access_token=${access_token}&refresh_token=${refresh_token}&type=${type}`;
}
// Call the function to intercept the auth callback
diff --git a/supabase/functions/postmark/addNoteToContact.ts b/supabase/functions/postmark/addNoteToContact.ts
index 0148a43a..605800e2 100644
--- a/supabase/functions/postmark/addNoteToContact.ts
+++ b/supabase/functions/postmark/addNoteToContact.ts
@@ -123,5 +123,8 @@ export const addNoteToContact = async ({
{ status: 500 }
);
- return new Response('OK');
+ await supabaseAdmin
+ .from('contacts')
+ .update({ last_seen: new Date() })
+ .eq('id', contact.id);
};
diff --git a/supabase/functions/postmark/extractMailContactData.ts b/supabase/functions/postmark/extractMailContactData.ts
index ed96ffac..b434d13c 100644
--- a/supabase/functions/postmark/extractMailContactData.ts
+++ b/supabase/functions/postmark/extractMailContactData.ts
@@ -24,19 +24,22 @@ export const extractMailContactData = (
Name: string;
}[]
) => {
- // We only support one recipient for now
- const contact = ToFull[0];
-
- const domain = contact.Email.split('@').at(-1);
- const fullName =
- contact.Name ||
- contact.Email.split('@').slice(0, -1).join(' ').split('.').join(' ');
- let firstName = '';
- let lastName = fullName;
- if (fullName && fullName.includes(' ')) {
- const parts = fullName.split(' ');
- firstName = parts[0];
- lastName = parts.slice(1).join(' ');
- }
- return { firstName, lastName, email: contact.Email, domain };
+ return ToFull.map(contact => {
+ const domain = contact.Email.split('@').at(-1)!;
+ const fullName =
+ contact.Name ||
+ contact.Email.split('@')
+ .slice(0, -1)
+ .join(' ')
+ .split('.')
+ .join(' ');
+ let firstName = '';
+ let lastName = fullName;
+ if (fullName && fullName.includes(' ')) {
+ const parts = fullName.split(' ');
+ firstName = parts[0];
+ lastName = parts.slice(1).join(' ');
+ }
+ return { firstName, lastName, email: contact.Email, domain };
+ });
};
diff --git a/supabase/functions/postmark/index.ts b/supabase/functions/postmark/index.ts
index a95fd514..c18e603e 100644
--- a/supabase/functions/postmark/index.ts
+++ b/supabase/functions/postmark/index.ts
@@ -4,9 +4,9 @@
// Setup type definitions for built-in Supabase Runtime APIs
import 'jsr:@supabase/functions-js/edge-runtime.d.ts';
-import { getExpectedAuthorization } from './getExpectedAuthorization.ts';
-import { extractMailContactData } from './extractMailContactData.ts';
import { addNoteToContact } from './addNoteToContact.ts';
+import { extractMailContactData } from './extractMailContactData.ts';
+import { getExpectedAuthorization } from './getExpectedAuthorization.ts';
import { getNoteContent } from './getNoteContent.ts';
const webhookUser = Deno.env.get('POSTMARK_WEBHOOK_USER');
@@ -46,24 +46,31 @@ Deno.serve(async req => {
);
}
- const { firstName, lastName, email, domain } =
- extractMailContactData(ToFull);
- if (!email) {
- // 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 email from ToFull: ${ToFull}`, {
- status: 403,
+ const contacts = extractMailContactData(ToFull);
+
+ for (const { firstName, lastName, email, domain } of contacts) {
+ if (!email) {
+ // 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 email from ToFull: ${ToFull}`,
+ {
+ status: 403,
+ }
+ );
+ }
+
+ await addNoteToContact({
+ salesEmail,
+ email,
+ domain,
+ firstName,
+ lastName,
+ noteContent,
});
}
- return await addNoteToContact({
- salesEmail,
- email,
- domain,
- firstName,
- lastName,
- noteContent,
- });
+ return new Response('OK');
});
const checkRequestTypeAndHeaders = (req: Request) => {
diff --git a/supabase/templates/invite.html b/supabase/templates/invite.html
index 5bb1ddc5..7cb5fbc1 100644
--- a/supabase/templates/invite.html
+++ b/supabase/templates/invite.html
@@ -62,11 +62,6 @@
class="button"
>Confirm my account</a
>
- <p>
- <strong>Warning:</strong> If the password reset request did
- not originate from you, please contact us immediately as
- this may be a fraudulent attempt.
- </p>
<p>See you soon!</p>
<p>Atomic CRM team</p>
</div>
diff --git a/supabase/templates/recovery.html b/supabase/templates/recovery.html
index 33558a1c..ee603807 100644
--- a/supabase/templates/recovery.html
+++ b/supabase/templates/recovery.html
@@ -49,7 +49,7 @@
<body>
<div class="container">
<div class="header">
- <h2>Reset your password</h2>
+ <h2>Reset Your Atomic CRM Password</h2>
</div>
<div class="content">
<p>Hello,</p>