Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
✨ Hide powered by (#2105)
Luke Velladb8971cddb93
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.jsonindex 98eb0b789..322059e21 100644--- a/apps/web/public/locales/en/app.json+++ b/apps/web/public/locales/en/app.json@@ -576,5 +576,8 @@"logosDescription": "Logo images used throughout the application","logo": "Logo","logoIcon": "Logo Icon",- "logoDark": "Logo (Dark Mode)"+ "logoDark": "Logo (Dark Mode)",+ "attribution": "Attribution",+ "attributionDescription": "Control the visibility of the attribution text",+ "hideAttribution": "Hide Attribution"}diff --git a/apps/web/src/app/[locale]/control-panel/branding/page.tsx b/apps/web/src/app/[locale]/control-panel/branding/page.tsxindex 71fb3960c..78d0e1a3a 100644--- a/apps/web/src/app/[locale]/control-panel/branding/page.tsx+++ b/apps/web/src/app/[locale]/control-panel/branding/page.tsx@@ -1,4 +1,5 @@import { Alert, AlertDescription } from "@rallly/ui/alert";+import { Switch } from "@rallly/ui/switch";import { CodeIcon, GemIcon } from "lucide-react";import type { Metadata } from "next";import {@@ -22,6 +23,7 @@ import {getLogoIconUrl,getLogoUrl,getPrimaryColor,+ shouldHideAttribution,} from "@/features/branding/queries";import { loadInstanceLicense } from "@/features/licensing/data";import { getTranslation } from "@/i18n/server";@@ -37,6 +39,7 @@ async function loadData() {logoUrlDark: logoUrls.dark,hasWhiteLabelAddon: !!license?.whiteLabelAddon,logoIconUrl: getLogoIconUrl(),+ hideAttribution: await shouldHideAttribution(),};}@@ -67,6 +70,7 @@ export default async function BrandingPage() {logoUrlDark,logoIconUrl,hasWhiteLabelAddon,+ hideAttribution,} = await loadData();return (@@ -212,6 +216,33 @@ export default async function BrandingPage() {</div></PageSectionContent></PageSection>+ <PageSection variant="card">+ <PageSectionHeader>+ <PageSectionTitle>+ <Trans i18nKey="attribution" defaults="Attribution" />+ </PageSectionTitle>+ <PageSectionDescription>+ <Trans+ i18nKey="attributionDescription"+ defaults="Control the visibility of the attribution text"+ />+ </PageSectionDescription>+ </PageSectionHeader>+ <PageSectionContent>+ <div className="space-y-2">+ <div className="text-muted-foreground text-xs">+ <Trans+ i18nKey="hideAttribution"+ defaults="Hide Attribution"+ />+ </div>+ <div className="flex items-center gap-2">+ <Switch checked={hideAttribution} disabled />+ </div>+ <SetEnvironmentVariableAlert variable="HIDE_ATTRIBUTION" />+ </div>+ </PageSectionContent>+ </PageSection></PageSectionGroup></SettingsPageContent></SettingsPage>diff --git a/apps/web/src/app/[locale]/layout.tsx b/apps/web/src/app/[locale]/layout.tsxindex 028aa3669..f74b3b087 100644--- a/apps/web/src/app/[locale]/layout.tsx+++ b/apps/web/src/app/[locale]/layout.tsx@@ -13,7 +13,11 @@ import { requireUser } from "@/auth/data";import { UserProvider } from "@/components/user-provider";import { PreferencesProvider } from "@/contexts/preferences";import { env } from "@/env";-import { getBrandingCssProperties } from "@/features/branding/queries";+import { BrandingProvider } from "@/features/branding/client";+import {+ getBrandingCssProperties,+ shouldHideAttribution,+} from "@/features/branding/queries";import { ThemeProvider } from "@/features/theme/client";import type { UserDTO } from "@/features/user/schema";import { I18nProvider } from "@/i18n/client";@@ -73,7 +77,10 @@ export default async function Root({const { locale } = await params;const { user } = await loadData();- const brandingStyles = await getBrandingCssProperties();+ const [brandingStyles, hideAttribution] = await Promise.all([+ getBrandingCssProperties(),+ shouldHideAttribution(),+ ]);return (<html@@ -85,38 +92,40 @@ export default async function Root({<body><ThemeProvider><FeatureFlagsProvider value={featureFlagConfig}>- <Toaster />- <I18nProvider locale={locale}>- <TRPCProvider>- <LazyMotion features={domAnimation}>- <PostHogProvider>- <PostHogIdentify- distinctId={user && !user.isGuest ? user.id : undefined}- />- <PostHogPageView />- <TooltipProvider>- <UserProvider user={user ?? undefined}>- <LocaleSync userLocale={user?.locale ?? locale} />- <PreferencesProvider- initialValue={{- timeFormat: user?.timeFormat,- timeZone: user?.timeZone,- weekStart: user?.weekStart,- }}- >- <TimezoneProvider initialTimezone={user?.timeZone}>- <ConnectedDayjsProvider>- {children}- <TimeZoneChangeDetector />- </ConnectedDayjsProvider>- </TimezoneProvider>- </PreferencesProvider>- </UserProvider>- </TooltipProvider>- </PostHogProvider>- </LazyMotion>- </TRPCProvider>- </I18nProvider>+ <BrandingProvider value={{ hideAttribution }}>+ <Toaster />+ <I18nProvider locale={locale}>+ <TRPCProvider>+ <LazyMotion features={domAnimation}>+ <PostHogProvider>+ <PostHogIdentify+ distinctId={user && !user.isGuest ? user.id : undefined}+ />+ <PostHogPageView />+ <TooltipProvider>+ <UserProvider user={user ?? undefined}>+ <LocaleSync userLocale={user?.locale ?? locale} />+ <PreferencesProvider+ initialValue={{+ timeFormat: user?.timeFormat,+ timeZone: user?.timeZone,+ weekStart: user?.weekStart,+ }}+ >+ <TimezoneProvider initialTimezone={user?.timeZone}>+ <ConnectedDayjsProvider>+ {children}+ <TimeZoneChangeDetector />+ </ConnectedDayjsProvider>+ </TimezoneProvider>+ </PreferencesProvider>+ </UserProvider>+ </TooltipProvider>+ </PostHogProvider>+ </LazyMotion>+ </TRPCProvider>+ </I18nProvider>+ </BrandingProvider></FeatureFlagsProvider></ThemeProvider></body>diff --git a/apps/web/src/app/api/send-email/route.ts b/apps/web/src/app/api/send-email/route.tsindex 5f4961745..6f02c48d4 100644--- a/apps/web/src/app/api/send-email/route.ts+++ b/apps/web/src/app/api/send-email/route.ts@@ -15,7 +15,7 @@ export const POST = async (req: NextRequest) => {// TODO: Add validation for templateName and options- const emailClient = getEmailClient(body.locale);+ const emailClient = await getEmailClient(body.locale);try {await emailClient.sendTemplate(body.templateName, body.options);diff --git a/apps/web/src/app/api/stripe/webhook/handlers/checkout/completed.ts b/apps/web/src/app/api/stripe/webhook/handlers/checkout/completed.tsindex a855c7127..34da8599f 100644--- a/apps/web/src/app/api/stripe/webhook/handlers/checkout/completed.ts+++ b/apps/web/src/app/api/stripe/webhook/handlers/checkout/completed.ts@@ -70,7 +70,7 @@ async function handleSelfHostedCheckoutSessionCompleted();}- const emailClient = getEmailClient();+ const emailClient = await getEmailClient();await emailClient.sendTemplate("LicenseKeyEmail", {to: email,diff --git a/apps/web/src/app/api/trpc/[trpc]/route.ts b/apps/web/src/app/api/trpc/[trpc]/route.tsindex 44d726991..c153d567c 100644--- a/apps/web/src/app/api/trpc/[trpc]/route.ts+++ b/apps/web/src/app/api/trpc/[trpc]/route.ts@@ -30,8 +30,8 @@ const handler = async (req: NextRequest) => {isGuest: session.user.isGuest,locale: session.user.locale ?? reqLocale,image: session.user.image ?? undefined,- getEmailClient: () =>- getEmailClient(session.user?.locale ?? undefined),+ getEmailClient: async () =>+ await getEmailClient(session.user?.locale ?? undefined),isLegacyGuest: session.legacy && session.user.isGuest,}: undefined;diff --git a/apps/web/src/components/poll/poll-footer.tsx b/apps/web/src/components/poll/poll-footer.tsxindex 5a3f5f850..5a0be561d 100644--- a/apps/web/src/components/poll/poll-footer.tsx+++ b/apps/web/src/components/poll/poll-footer.tsx@@ -1,8 +1,16 @@+"use client";import Link from "next/link";import { Trans } from "@/components/trans";+import { useBranding } from "@/features/branding/client";export function PollFooter() {+ const { hideAttribution } = useBranding();++ if (hideAttribution) {+ return null;+ }+return (<div className="pt-4 pb-12 text-center text-muted-foreground text-sm"><Transdiff --git a/apps/web/src/env.ts b/apps/web/src/env.tsindex 57436d497..f2da09a8b 100644--- a/apps/web/src/env.ts+++ b/apps/web/src/env.ts@@ -124,6 +124,11 @@ export const env = createEnv({LOGO_URL: z.url().optional(),LOGO_URL_DARK: z.url().optional(),LOGO_ICON_URL: z.url().optional(),+ /**+ * Hide attribution text on invite pages and emails+ * @default "false"+ */+ HIDE_ATTRIBUTION: z.enum(["true", "false"]).default("false"),/****/@@ -204,6 +209,7 @@ export const env = createEnv({LOGO_URL_DARK: process.env.LOGO_URL_DARK,LOGO_ICON_URL: process.env.LOGO_ICON_URL,APP_NAME: process.env.APP_NAME,+ HIDE_ATTRIBUTION: process.env.HIDE_ATTRIBUTION,KV_REST_API_URL: process.env.KV_REST_API_URL,KV_REST_API_TOKEN: process.env.KV_REST_API_TOKEN,KV_URL: process.env.KV_URL,diff --git a/apps/web/src/features/branding/client.tsx b/apps/web/src/features/branding/client.tsxnew file mode 100644index 000000000..54ef14a6a--- /dev/null+++ b/apps/web/src/features/branding/client.tsx@@ -0,0 +1,32 @@+"use client";++import React from "react";++export interface BrandingConfig {+ hideAttribution: boolean;+}++const BrandingContext = React.createContext<BrandingConfig | undefined>(+ undefined,+);++interface BrandingProviderProps {+ value: BrandingConfig;+ children: React.ReactNode;+}++export function BrandingProvider({ value, children }: BrandingProviderProps) {+ return (+ <BrandingContext.Provider value={value}>+ {children}+ </BrandingContext.Provider>+ );+}++export function useBranding(): BrandingConfig {+ const context = React.useContext(BrandingContext);+ if (context === undefined) {+ throw new Error("useBranding must be used within a BrandingProvider");+ }+ return context;+}diff --git a/apps/web/src/features/branding/queries.ts b/apps/web/src/features/branding/queries.tsindex 51f0dd73d..f6ea0fd7a 100644--- a/apps/web/src/features/branding/queries.ts+++ b/apps/web/src/features/branding/queries.ts@@ -2,6 +2,7 @@ import "server-only";import type React from "react";import { env } from "@/env";+import { loadInstanceLicense } from "@/features/licensing/data";import { adjustColorForContrast, getForegroundColor } from "@/utils/color";import {DARK_MODE_BACKGROUND,@@ -51,3 +52,22 @@ export function getLogoUrl() {export function getLogoIconUrl() {return env.LOGO_ICON_URL ?? DEFAULT_LOGO_ICON_URL;}++export function getHideAttribution() {+ // This function is called synchronously in feature flag config,+ // so we need to check the license synchronously+ // The actual license check will be done at runtime when needed+ return env.HIDE_ATTRIBUTION === "true";+}++export async function shouldHideAttribution() {+ const license = await loadInstanceLicense();+ const hasWhiteLabelAddon = !!license?.whiteLabelAddon;++ // Only hide if both the env var is set and the user has white-label add-on+ if (!hasWhiteLabelAddon) {+ return false;+ }++ return env.HIDE_ATTRIBUTION === "true";+}diff --git a/apps/web/src/features/feedback/actions.ts b/apps/web/src/features/feedback/actions.tsindex 8c5acab1b..6f5a387f2 100644--- a/apps/web/src/features/feedback/actions.ts+++ b/apps/web/src/features/feedback/actions.ts@@ -16,7 +16,8 @@ export const submitFeedbackAction = authActionClient.action(async ({ ctx, parsedInput }) => {try {const { content } = parsedInput;- getEmailClient().sendEmail({+ const emailClient = await getEmailClient();+ emailClient.sendEmail({to: "[email protected]",subject: "Feedback",text: `User: ${ctx.user.name} (${ctx.user.email})\n\n${content}`,diff --git a/apps/web/src/features/scheduled-event/actions.ts b/apps/web/src/features/scheduled-event/actions.tsindex 12ef5d4d8..e0239735d 100644--- a/apps/web/src/features/scheduled-event/actions.ts+++ b/apps/web/src/features/scheduled-event/actions.ts@@ -112,7 +112,8 @@ export const cancelEventAction = spaceActionClientinviteeTimeZone: attendee.inviteeTimeZone,});- getEmailClient().queueTemplate("EventCanceledEmail", {+ const emailClient = await getEmailClient();+ emailClient.queueTemplate("EventCanceledEmail", {to: attendee.inviteeEmail,props: {title: event.title,diff --git a/apps/web/src/features/space/actions.ts b/apps/web/src/features/space/actions.tsindex 4faf890d7..d83ccbf6b 100644--- a/apps/web/src/features/space/actions.ts+++ b/apps/web/src/features/space/actions.ts@@ -294,7 +294,7 @@ export const inviteMemberAction = spaceActionClient},});- const emailClient = getEmailClient(+ const emailClient = await getEmailClient(existingUser?.locale ?? ctx.user.locale,);diff --git a/apps/web/src/lib/auth.ts b/apps/web/src/lib/auth.tsindex 892f4a9ac..78466a9a4 100644--- a/apps/web/src/lib/auth.ts+++ b/apps/web/src/lib/auth.ts@@ -83,7 +83,7 @@ export const authLib = betterAuth({const locale ="locale" in user ? (user.locale as string) : await getLocale();- await getEmailClient(locale).sendTemplate("ResetPasswordEmail", {+ await (await getEmailClient(locale)).sendTemplate("ResetPasswordEmail", {to: user.email,props: {resetLink: url,@@ -130,7 +130,7 @@ export const authLib = betterAuth({overrideDefaultEmailVerification: true,async sendVerificationOTP({ email, otp, type }) {const locale = await getLocale(); // TODO: Get locale from email- const emailClient = getEmailClient(locale);+ const emailClient = await getEmailClient(locale);switch (type) {// We're not actually using the sign-in type anymore since we just we have `autoSignInAfterVerification` enabled.// This lets us keep things a bit simpler since we share the same verification flow for both login and registration.diff --git a/apps/web/src/trpc/routers/polls.ts b/apps/web/src/trpc/routers/polls.tsindex 292d682a0..44a8aa801 100644--- a/apps/web/src/trpc/routers/polls.ts+++ b/apps/web/src/trpc/routers/polls.ts@@ -290,7 +290,10 @@ export const polls = router({});if (user) {- getEmailClient(ctx.user.locale).queueTemplate("NewPollEmail", {+ const emailClient = await getEmailClient(+ ctx.user.locale ?? undefined,+ );+ emailClient.queueTemplate("NewPollEmail", {to: user.email,props: {title: poll.title,@@ -786,6 +789,7 @@ export const polls = router({select: {name: true,email: true,+ locale: true,},},participants: {@@ -1004,7 +1008,8 @@ export const polls = router({timeZone: scheduledEvent.timeZone,});- getEmailClient(ctx.user.locale).queueTemplate("FinalizeHostEmail", {+ const emailClient = await getEmailClient(poll.user.locale ?? undefined);+ emailClient.queueTemplate("FinalizeHostEmail", {to: poll.user.email,props: {name: poll.user.name,@@ -1038,22 +1043,24 @@ export const polls = router({timeZone: scheduledEvent.timeZone,inviteeTimeZone: p.timeZone,});- getEmailClient(p.locale ?? undefined).queueTemplate(- "FinalizeParticipantEmail",- {- to: p.email,- props: {- pollUrl: absoluteUrl(`/invite/${poll.id}`),- title: poll.title,- hostName: poll.user?.name ?? "",- date,- day,- dow,- time,- },- attachments: [{ filename: "event.ics", content: event.value }],+ const emailClient = await getEmailClient(p.locale ?? undefined);+ emailClient.queueTemplate("FinalizeParticipantEmail", {+ to: p.email,+ props: {+ pollUrl: absoluteUrl(`/invite/${poll.id}`),+ title: poll.title,+ hostName: poll.user?.name ?? "",+ date,+ day,+ dow,+ time,},- );+ icalEvent: {+ filename: "invite.ics",+ method: "request",+ content: event.value,+ },+ });}ctx.posthog?.capture({diff --git a/apps/web/src/trpc/routers/polls/comments.ts b/apps/web/src/trpc/routers/polls/comments.tsindex 2236e77c2..45e3b1f15 100644--- a/apps/web/src/trpc/routers/polls/comments.ts+++ b/apps/web/src/trpc/routers/polls/comments.ts@@ -156,20 +156,20 @@ export const comments = router({{ ttl: 0 },);- getEmailClient(watcher.user.locale ?? undefined).queueTemplate(- "NewCommentEmail",- {- to: email,- props: {- authorName,- pollUrl: absoluteUrl(`/poll/${poll.id}`),- disableNotificationsUrl: absoluteUrl(- `/api/notifications/unsubscribe?token=${token}`,- ),- title: poll.title,- },- },+ const emailClient = await getEmailClient(+ watcher.user.locale ?? undefined,);+ emailClient.queueTemplate("NewCommentEmail", {+ to: email,+ props: {+ authorName,+ pollUrl: absoluteUrl(`/poll/${poll.id}`),+ disableNotificationsUrl: absoluteUrl(+ `/api/notifications/unsubscribe?token=${token}`,+ ),+ title: poll.title,+ },+ });}// Track comment addition analyticsdiff --git a/apps/web/src/trpc/routers/polls/participants.ts b/apps/web/src/trpc/routers/polls/participants.tsindex 57d980110..4f048205d 100644--- a/apps/web/src/trpc/routers/polls/participants.ts+++ b/apps/web/src/trpc/routers/polls/participants.ts@@ -79,20 +79,18 @@ async function sendNewParticipantNotifcationEmail({{ watcherId: watcher.id, pollId },{ ttl: 0 },);- await getEmailClient(watcherLocale).sendTemplate(- "NewParticipantEmail",- {- to: email,- props: {- participantName,- pollUrl: absoluteUrl(`/poll/${pollId}`),- disableNotificationsUrl: absoluteUrl(- `/api/notifications/unsubscribe?token=${token}`,- ),- title: pollTitle,- },+ const emailClient = await getEmailClient(watcherLocale);+ await emailClient.sendTemplate("NewParticipantEmail", {+ to: email,+ props: {+ participantName,+ pollUrl: absoluteUrl(`/poll/${pollId}`),+ disableNotificationsUrl: absoluteUrl(+ `/api/notifications/unsubscribe?token=${token}`,+ ),+ title: pollTitle,},- );+ });} catch (err) {Sentry.captureException(err);}@@ -287,18 +285,19 @@ export const participants = router({if (email) {const token = await createParticipantEditToken(ctx.user.id);- getEmailClient(ctx.user.locale).queueTemplate(- "NewParticipantConfirmationEmail",- {- to: email,- props: {- title: participant.poll.title,- editSubmissionUrl: absoluteUrl(- `/invite/${participant.poll.id}?token=${token}`,- ),- },- },+ const emailClient = await getEmailClient(+ ctx.user.locale ?? undefined,);++ emailClient.queueTemplate("NewParticipantConfirmationEmail", {+ to: email,+ props: {+ title: participant.poll.title,+ editSubmissionUrl: absoluteUrl(+ `/invite/${participant.poll.id}?token=${token}`,+ ),+ },+ });}waitUntil(diff --git a/apps/web/src/trpc/routers/user.ts b/apps/web/src/trpc/routers/user.tsindex 0ecdf894d..47b9007ef 100644--- a/apps/web/src/trpc/routers/user.ts+++ b/apps/web/src/trpc/routers/user.ts@@ -128,7 +128,9 @@ export const user = router({},);- getEmailClient(ctx.user.locale).sendTemplate("ChangeEmailRequest", {+ const emailClient = await getEmailClient();++ emailClient.sendTemplate("ChangeEmailRequest", {to: input.email,props: {verificationUrl: absoluteUrl(diff --git a/apps/web/src/utils/emails.ts b/apps/web/src/utils/emails.tsindex 4552af38a..24653665c 100644--- a/apps/web/src/utils/emails.ts+++ b/apps/web/src/utils/emails.ts@@ -8,9 +8,10 @@ import {getAppName,getLogoIconUrl,getPrimaryColor,+ shouldHideAttribution,} from "@/features/branding/queries";-export const getEmailClient = (locale?: string) => {+export const getEmailClient = async (locale?: string) => {return new EmailClient({provider: {name: (process.env.EMAIL_PROVIDER as SupportedEmailProviders) ?? "smtp",@@ -28,6 +29,7 @@ export const getEmailClient = (locale?: string) => {supportEmail: env.SUPPORT_EMAIL,primaryColor: getPrimaryColor().light,appName: getAppName(),+ hideAttribution: await shouldHideAttribution(),},locale,onError: (e) => {diff --git a/packages/emails/src/components/email-layout.tsx b/packages/emails/src/components/email-layout.tsxindex d1ed8ff42..f60d2729d 100644--- a/packages/emails/src/components/email-layout.tsx+++ b/packages/emails/src/components/email-layout.tsx@@ -34,6 +34,7 @@ export const EmailLayout = ({poweredBy = true,}: React.PropsWithChildren<EmailLayoutProps>) => {const { logoUrl } = ctx;+ const shouldShowPoweredBy = poweredBy && !ctx.hideAttribution;return (<Html><Head />@@ -49,7 +50,7 @@ export const EmailLayout = ({alt={ctx.appName}/>{children}- {poweredBy ? (+ {shouldShowPoweredBy ? (<Section><Text light={true}><Transdiff --git a/packages/emails/src/send-email.tsx b/packages/emails/src/send-email.tsxindex 0b1c290b2..0a427327a 100644--- a/packages/emails/src/send-email.tsx+++ b/packages/emails/src/send-email.tsx@@ -57,6 +57,7 @@ type EmailClientConfig = {supportEmail: string;primaryColor: string;appName: string;+ hideAttribution: boolean;};locale?: string;diff --git a/packages/emails/src/types.ts b/packages/emails/src/types.tsindex a0b28edb9..3a5a317e3 100644--- a/packages/emails/src/types.ts+++ b/packages/emails/src/types.ts@@ -12,6 +12,7 @@ export type EmailContext = {t: TFunction;appName: string;primaryColor?: string;+ hideAttribution?: boolean;};export type TemplateName = keyof EmailTemplates;