Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix

Marc Seitze37ce2d0f6ec
diff --git a/lib/unsend.ts b/lib/unsend.ts
index b7510868..3afc9e19 100644
--- a/lib/unsend.ts
+++ b/lib/unsend.ts
@@ -2,14 +2,18 @@ import { Unsend } from "unsend";
import prisma from "@/lib/prisma";
-const unsend = new Unsend(
- process.env.UNSEND_API_KEY,
- process.env.UNSEND_BASE_URL,
-);
+const unsend = process.env.UNSEND_API_KEY
+ ? new Unsend(process.env.UNSEND_API_KEY, process.env.UNSEND_BASE_URL)
+ : null;
const contactBookId = process.env.UNSEND_CONTACT_BOOK_ID as string;
const subscribe = async (email: string) => {
+ if (!unsend) {
+ console.error("UNSEND_API_KEY is not set in the .env. Skipping.");
+ return;
+ }
+
if (!contactBookId) {
console.error("UNSEND_CONTACT_BOOK_ID is not set in the .env. Skipping.");
return;
@@ -34,6 +38,11 @@ const subscribe = async (email: string) => {
};
const unsubscribe = async (email: string): Promise<void> => {
+ if (!unsend) {
+ console.error("UNSEND_API_KEY is not set in the .env. Skipping.");
+ return;
+ }
+
if (!contactBookId) {
console.error("UNSEND_CONTACT_BOOK_ID is not set in the .env. Skipping.");
return;