feats(configs): add email push config for subdomain apply
This commit is contained in:
@@ -88,7 +88,7 @@ export default function AppConfigs({}: {}) {
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<Collapsible defaultOpen className="group">
|
||||
<Collapsible className="group">
|
||||
<CollapsibleTrigger className="flex w-full items-center justify-between bg-neutral-50 px-4 py-5 dark:bg-neutral-900">
|
||||
<div className="text-lg font-bold">{t("App Configs")}</div>
|
||||
<Icons.chevronDown className="ml-auto size-4" />
|
||||
@@ -637,36 +637,6 @@ export default function AppConfigs({}: {}) {
|
||||
</div>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
|
||||
{/* Webhook */}
|
||||
{/* <div className="flex flex-col items-start justify-start gap-3">
|
||||
<div className="space-y-1 leading-none">
|
||||
<p className="font-medium">Webhook</p>
|
||||
<p className="text-xs text-muted-foreground"></p>
|
||||
</div>
|
||||
{configs && (
|
||||
<div className="flex w-full items-start gap-2">
|
||||
<Textarea
|
||||
className="h-16 max-h-32 min-h-9 resize-y bg-white dark:bg-neutral-700"
|
||||
placeholder=""
|
||||
rows={5}
|
||||
// defaultValue={configs.catch_all_emails}
|
||||
// value={catchAllEmails}
|
||||
disabled
|
||||
// onChange={(e) => setCatchAllEmails(e.target.value)}
|
||||
/>
|
||||
<Button
|
||||
className="h-9 text-nowrap"
|
||||
disabled
|
||||
onClick={() =>
|
||||
handleChange(catchAllEmails, "catch_all_emails", "STRING")
|
||||
}
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div> */}
|
||||
</div>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
@@ -697,6 +667,31 @@ export default function AppConfigs({}: {}) {
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between space-x-2">
|
||||
<div className="space-y-1 leading-none">
|
||||
<p className="font-medium">
|
||||
{t("Application Status Email Notifications")}
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{t(
|
||||
"Send email notifications for subdomain application status updates; Notifies administrators when users submit applications and notifies users of approval results; Only available when subdomain application mode is enabled",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
{configs && (
|
||||
<Switch
|
||||
defaultChecked={configs.enable_subdomain_status_email_pusher}
|
||||
onCheckedChange={(v) =>
|
||||
handleChange(
|
||||
v,
|
||||
"enable_subdomain_status_email_pusher",
|
||||
"BOOLEAN",
|
||||
)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
|
||||
@@ -33,6 +33,7 @@ export async function GET(req: NextRequest) {
|
||||
"tg_email_target_white_list",
|
||||
"enable_email_registration_suffix_limit",
|
||||
"email_registration_suffix_limit_white_list",
|
||||
"enable_subdomain_status_email_pusher",
|
||||
]);
|
||||
|
||||
return Response.json(configs, { status: 200 });
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from "@/lib/dto/cloudflare-dns-record";
|
||||
import { getDomainsByFeature } from "@/lib/dto/domains";
|
||||
import { getPlanQuota } from "@/lib/dto/plan";
|
||||
import { getConfigValue } from "@/lib/dto/system-config";
|
||||
import { getMultipleConfigs } from "@/lib/dto/system-config";
|
||||
import { checkUserStatus, getFirstAdminUser } from "@/lib/dto/user";
|
||||
import { applyRecordEmailHtml, resend } from "@/lib/email";
|
||||
import { reservedDomains } from "@/lib/enums";
|
||||
@@ -86,12 +86,13 @@ export async function POST(req: Request) {
|
||||
});
|
||||
}
|
||||
|
||||
const enableSubdomainApply = await getConfigValue<boolean>(
|
||||
const configs = await getMultipleConfigs([
|
||||
"enable_subdomain_apply",
|
||||
);
|
||||
"enable_subdomain_status_email_pusher",
|
||||
]);
|
||||
|
||||
// apply subdomain
|
||||
if (enableSubdomainApply) {
|
||||
if (configs.enable_subdomain_apply) {
|
||||
const res = await createUserRecord(user.id, {
|
||||
record_id: generateSecret(16),
|
||||
zone_id: matchedZone.cf_zone_id,
|
||||
@@ -115,7 +116,7 @@ export async function POST(req: Request) {
|
||||
});
|
||||
}
|
||||
const admin_user = await getFirstAdminUser();
|
||||
if (admin_user) {
|
||||
if (configs.enable_subdomain_status_email_pusher && admin_user) {
|
||||
await resend.emails.send({
|
||||
from: env.RESEND_FROM_EMAIL,
|
||||
to: admin_user.email || "",
|
||||
|
||||
@@ -3,6 +3,7 @@ import { siteConfig } from "@/config/site";
|
||||
import { createDNSRecord } from "@/lib/cloudflare";
|
||||
import { updateUserRecordReview } from "@/lib/dto/cloudflare-dns-record";
|
||||
import { getDomainsByFeature } from "@/lib/dto/domains";
|
||||
import { getMultipleConfigs } from "@/lib/dto/system-config";
|
||||
import { checkUserStatus, getUserById } from "@/lib/dto/user";
|
||||
import { applyRecordToUserEmailHtml, resend } from "@/lib/email";
|
||||
import { getCurrentUser } from "@/lib/session";
|
||||
@@ -66,8 +67,11 @@ export async function POST(req: Request) {
|
||||
active: 0,
|
||||
});
|
||||
|
||||
const configs = await getMultipleConfigs([
|
||||
"enable_subdomain_status_email_pusher",
|
||||
]);
|
||||
const userInfo = await getUserById(userId);
|
||||
if (userInfo) {
|
||||
if (configs.enable_subdomain_status_email_pusher && userInfo) {
|
||||
await resend.emails.send({
|
||||
from: env.RESEND_FROM_EMAIL,
|
||||
to: userInfo.email || "",
|
||||
|
||||
@@ -342,7 +342,7 @@ export function RecordForm({
|
||||
/>
|
||||
</div>
|
||||
<p className="p-1 text-[13px] text-muted-foreground">
|
||||
{t("At least 20 characters")}
|
||||
{t("At least 20 characters, Max 100 characters")}
|
||||
</p>
|
||||
</FormSectionColumns>
|
||||
)}
|
||||
|
||||
+4
-2
@@ -100,7 +100,7 @@
|
||||
"The administrator has enabled application mode": "The administrator has enabled application mode",
|
||||
"After submission, you need to wait for administrator approval before the record takes effect": "After submission, you need to wait for administrator approval before the record takes effect",
|
||||
"What are you planning to use the subdomain for?": "What are you planning to use the subdomain for?",
|
||||
"At least 20 characters": "At least 20 characters",
|
||||
"At least 20 characters, Max 100 characters": "At least 20 characters, Max 100 characters",
|
||||
"User email": "User email",
|
||||
"Domain": "Domain",
|
||||
"No domains configured": "No domains configured",
|
||||
@@ -533,6 +533,8 @@
|
||||
"Enable eamil suffix limit, only works for resend email login and email password login methods": "Enable eamil suffix limit, only works for resend email login and email password login methods",
|
||||
"Need to configure": "Need to configure",
|
||||
"Email Suffix White List": "Email Suffix White List",
|
||||
"Set email suffix white list, split by comma, such as: gmail-com,yahoo-com,hotmail-com": "Set email suffix white list, split by comma, such as: gmail.com,yahoo.com,hotmail.com"
|
||||
"Set email suffix white list, split by comma, such as: gmail-com,yahoo-com,hotmail-com": "Set email suffix white list, split by comma, such as: gmail.com,yahoo.com,hotmail.com",
|
||||
"Application Status Email Notifications": "Application Status Email Notifications",
|
||||
"Send email notifications for subdomain application status updates; Notifies administrators when users submit applications and notifies users of approval results; Only available when subdomain application mode is enabled": "Send email notifications for subdomain application status updates; Notifies administrators when users submit applications and notifies users of approval results; Only available when subdomain application mode is enabled"
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -100,7 +100,7 @@
|
||||
"The administrator has enabled application mode": "管理员已启用 [用户申请 - 管理员审核] 模式",
|
||||
"After submission, you need to wait for administrator approval before the record takes effect": "提交后, 您需要等待管理员审核才能生效",
|
||||
"What are you planning to use the subdomain for?": "您计划使用此域名做什么?",
|
||||
"At least 20 characters": "至少 20 个字符",
|
||||
"At least 20 characters, Max 100 characters": "至少 20 个字符,最多 100 个字符",
|
||||
"User email": "用户邮箱",
|
||||
"Domain": "根域名",
|
||||
"No domains configured": "未配置域名",
|
||||
@@ -498,7 +498,7 @@
|
||||
"User Registration": "用户注册",
|
||||
"Allow users to sign up": "是否允许用户注册",
|
||||
"Subdomain Apply Mode": "子域名申请模式",
|
||||
"Enable subdomain apply mode, each submission requires administrator review": "启用子域名申请模式,用户每次提交新子域名需要管理员审核(邮件通知管理员审核,审核通过后邮件通知用户)",
|
||||
"Enable subdomain apply mode, each submission requires administrator review": "启用子域名申请模式,用户每次提交新子域名需要管理员审核",
|
||||
"Notification": "系统通知",
|
||||
"Set system notification, this will be displayed in the header": "设置系统通知,将在网页顶部显示",
|
||||
"Login Methods": "登录方式",
|
||||
@@ -533,6 +533,8 @@
|
||||
"Enable eamil suffix limit, only works for resend email login and email password login methods": "开启注册邮箱后缀限制,仅适用于 Resend 邮箱登录和账号密码登录方式",
|
||||
"Need to configure": "需要配置",
|
||||
"Email Suffix White List": "白名单",
|
||||
"Set email suffix white list, split by comma, such as: gmail-com,yahoo-com,hotmail-com": "设置邮箱后缀白名单,多个后缀请用逗号分隔,例如:gmail.com,yahoo.com,hotmail.com"
|
||||
"Set email suffix white list, split by comma, such as: gmail-com,yahoo-com,hotmail-com": "设置邮箱后缀白名单,多个后缀请用逗号分隔,例如:gmail.com,yahoo.com,hotmail.com",
|
||||
"Application Status Email Notifications": "申请状态邮件通知",
|
||||
"Send email notifications for subdomain application status updates; Notifies administrators when users submit applications and notifies users of approval results; Only available when subdomain application mode is enabled": "开启后,用户申请子域名时将邮件通知管理员审核,审核完成后邮件通知用户结果。此功能仅在子域申请模式开启时有效"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
-- 是否开启邮件推送(子域名申请状态)
|
||||
INSERT INTO "system_configs"
|
||||
(
|
||||
"key",
|
||||
"value",
|
||||
"type",
|
||||
"description"
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
'enable_subdomain_status_email_pusher',
|
||||
'false',
|
||||
'BOOLEAN',
|
||||
'是否开启邮件推送(子域名申请状态)'
|
||||
);
|
||||
|
||||
-- Catch-all 白名单邮箱
|
||||
INSERT INTO "system_configs"
|
||||
(
|
||||
"key",
|
||||
"value",
|
||||
"type",
|
||||
"description"
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
'catch_all_whitelist_emails',
|
||||
'',
|
||||
'STRING',
|
||||
'Catch-all 白名单邮箱'
|
||||
);
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user