From 025f422695256be2d65182247e77f57b5edaef5e Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 2 Apr 2026 20:16:58 -0400 Subject: [PATCH] chore: Disable public document subscription when SMTP is not configured (#11938) --- .../Sharing/Collection/PublicAccess.tsx | 52 ++++++++++--------- .../Sharing/Document/PublicAccess.tsx | 52 ++++++++++--------- app/scenes/Document/components/Header.tsx | 3 +- server/routes/api/shares/shares.ts | 4 ++ 4 files changed, 60 insertions(+), 51 deletions(-) diff --git a/app/components/Sharing/Collection/PublicAccess.tsx b/app/components/Sharing/Collection/PublicAccess.tsx index 8b4337f9eb..1c68e05500 100644 --- a/app/components/Sharing/Collection/PublicAccess.tsx +++ b/app/components/Sharing/Collection/PublicAccess.tsx @@ -207,31 +207,33 @@ function InnerPublicAccess( /> } /> - - {t("Email subscriptions")}  - - - - - - - } - actions={ - - } - /> + {env.EMAIL_ENABLED && ( + + {t("Email subscriptions")}  + + + + + + + } + actions={ + + } + /> + )} diff --git a/app/components/Sharing/Document/PublicAccess.tsx b/app/components/Sharing/Document/PublicAccess.tsx index cbe2782409..a43763b294 100644 --- a/app/components/Sharing/Document/PublicAccess.tsx +++ b/app/components/Sharing/Document/PublicAccess.tsx @@ -251,31 +251,33 @@ function PublicAccess( /> } /> - - {t("Email subscriptions")}  - - - - - - - } - actions={ - - } - /> + {env.EMAIL_ENABLED && ( + + {t("Email subscriptions")}  + + + + + + + } + actions={ + + } + /> + )} diff --git a/app/scenes/Document/components/Header.tsx b/app/scenes/Document/components/Header.tsx index d1aef18b02..b354e5f17b 100644 --- a/app/scenes/Document/components/Header.tsx +++ b/app/scenes/Document/components/Header.tsx @@ -34,6 +34,7 @@ import DocumentMenu from "~/menus/DocumentMenu"; import NewChildDocumentMenu from "~/menus/NewChildDocumentMenu"; import TableOfContentsMenu from "~/menus/TableOfContentsMenu"; import TemplatesMenu from "~/menus/TemplatesMenu"; +import env from "~/env"; import { documentEditPath } from "~/utils/routeHelpers"; import ObservingBanner from "./ObservingBanner"; import PublicBreadcrumb from "./PublicBreadcrumb"; @@ -213,7 +214,7 @@ function DocumentHeader({ } actions={ <> - {allowSubscriptions !== false && !user && ( + {allowSubscriptions !== false && !user && env.EMAIL_ENABLED && ( )} diff --git a/server/routes/api/shares/shares.ts b/server/routes/api/shares/shares.ts index c9b5acba2b..ab2a4d28ee 100644 --- a/server/routes/api/shares/shares.ts +++ b/server/routes/api/shares/shares.ts @@ -441,6 +441,10 @@ router.post( validate(T.SharesSubscribeSchema), transaction(), async (ctx: APIContext) => { + if (!env.EMAIL_ENABLED) { + throw InvalidRequestError("Email is not configured"); + } + const { shareId, documentId, email } = ctx.input.body; const { transaction } = ctx.state; const team = await getTeamFromContext(ctx, { includeStateCookie: false });