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 });