From cfcbc3fe26c4a48b02f57152852228cb46188f8b Mon Sep 17 00:00:00 2001 From: oiov Date: Mon, 28 Jul 2025 09:49:36 +0800 Subject: [PATCH] feat: add email forwarding configs --- app/(protected)/admin/system/app-configs.tsx | 82 ++++++++++++- app/(protected)/admin/system/s3-list.tsx | 5 +- app/api/admin/configs/route.ts | 2 + app/api/storage/admin/s3/files/short/route.ts | 2 +- app/api/v1/email-catcher/route.ts | 111 +++++++++++++++--- lib/dto/short-urls.ts | 4 +- locales/en.json | 6 +- locales/zh.json | 6 +- .../migrations/20250727164915/migration.sql | 30 +++++ public/sw.js.map | 2 +- 10 files changed, 222 insertions(+), 28 deletions(-) create mode 100644 prisma/migrations/20250727164915/migration.sql diff --git a/app/(protected)/admin/system/app-configs.tsx b/app/(protected)/admin/system/app-configs.tsx index c208b46..a0b2521 100644 --- a/app/(protected)/admin/system/app-configs.tsx +++ b/app/(protected)/admin/system/app-configs.tsx @@ -35,6 +35,7 @@ export default function AppConfigs({}: {}) { } = useSWR>("/api/admin/configs", fetcher); const [notification, setNotification] = useState(""); const [catchAllEmails, setCatchAllEmails] = useState(""); + const [forwardEmailTargets, setForwardEmailTargets] = useState(""); const [emailSuffix, setEmailSuffix] = useState(""); const [tgBotToken, setTgBotToken] = useState(""); const [tgChatId, setTgChatId] = useState(""); @@ -52,8 +53,9 @@ export default function AppConfigs({}: {}) { setTgChatId(configs?.tg_email_chat_id); setTgTemplate(configs?.tg_email_template); setTgWhiteList(configs?.tg_email_target_white_list); + setForwardEmailTargets(configs?.email_forward_targets); } - // 计算登录方式数量 + if (!isLoading) { let count = 0; if (configs?.enable_google_oauth) count++; @@ -365,7 +367,7 @@ export default function AppConfigs({}: {}) {
- {/* Catch-All */} + {/* Catch-All*/}
@@ -445,6 +447,82 @@ export default function AppConfigs({}: {}) {
+ {/* Forward Email to other email address */} + + +
+

+ {t("Email Forwarding")} +

+

+ {t( + "If enabled, forward all received emails to other platform email addresses (Send with Resend)", + )} +

+
+ {configs && ( +
e.stopPropagation()} + > + {configs.enable_email_forward && + !configs.email_forward_targets && ( + + {" "} + {t("Need to configure")} + + )} + + handleChange(v, "enable_email_forward", "BOOLEAN") + } + /> + +
+ )} +
+ +
+
+

{t("Forward Email Targets")}

+

+ {t( + "Set forward email address targets, split by comma if more than one, such as: 1@a-com,2@b-com, Only works when email forwarding is enabled", + )} +

+
+ {configs && ( +
+