mirror of
https://github.com/Awuqing/BackupX.git
synced 2026-09-04 23:16:41 +08:00
fix: route sms otp through webhook notifier
This commit is contained in:
@@ -5,18 +5,16 @@ describe('notification field config', () => {
|
||||
it('returns readable type labels', () => {
|
||||
expect(getNotificationTypeLabel('email')).toBe('Email')
|
||||
expect(getNotificationTypeLabel('telegram')).toBe('Telegram')
|
||||
expect(getNotificationTypeLabel('sms')).toBe('SMS Webhook')
|
||||
expect(getNotificationTypeLabel('webhook')).toBe('Webhook')
|
||||
})
|
||||
|
||||
it('returns required fields for each notification type', () => {
|
||||
const emailFields = getNotificationFieldConfigs('email')
|
||||
const webhookFields = getNotificationFieldConfigs('webhook')
|
||||
const telegramFields = getNotificationFieldConfigs('telegram')
|
||||
const smsFields = getNotificationFieldConfigs('sms')
|
||||
|
||||
expect(emailFields.some((field) => field.key === 'host' && field.required)).toBe(true)
|
||||
expect(webhookFields.some((field) => field.key === 'url' && field.required)).toBe(true)
|
||||
expect(telegramFields.some((field) => field.key === 'botToken' && field.required)).toBe(true)
|
||||
expect(smsFields.some((field) => field.key === 'url' && field.required)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -13,10 +13,6 @@ const FIELD_CONFIG_MAP: Record<NotificationType, NotificationFieldConfig[]> = {
|
||||
{ key: 'url', label: 'Webhook URL', type: 'input', required: true, placeholder: 'https://hooks.example.com/backupx' },
|
||||
{ key: 'secret', label: '共享密钥', type: 'password', placeholder: '可选', sensitive: true },
|
||||
],
|
||||
sms: [
|
||||
{ key: 'url', label: 'SMS Webhook URL', type: 'input', required: true, placeholder: 'https://sms-gateway.example.com/send', description: '仅允许 HTTPS 公网地址。' },
|
||||
{ key: 'secret', label: '共享密钥', type: 'password', placeholder: '可选', sensitive: true },
|
||||
],
|
||||
telegram: [
|
||||
{ key: 'botToken', label: 'Bot Token', type: 'password', required: true, placeholder: '123456:ABC', sensitive: true },
|
||||
{ key: 'chatId', label: 'Chat ID', type: 'input', required: true, placeholder: '-100xxxxxxxxxx' },
|
||||
@@ -27,7 +23,6 @@ export const notificationTypeOptions = [
|
||||
{ label: 'Email', value: 'email' },
|
||||
{ label: 'Webhook', value: 'webhook' },
|
||||
{ label: 'Telegram', value: 'telegram' },
|
||||
{ label: 'SMS Webhook', value: 'sms' },
|
||||
] as const
|
||||
|
||||
export function getNotificationTypeLabel(type: NotificationType) {
|
||||
@@ -38,8 +33,6 @@ export function getNotificationTypeLabel(type: NotificationType) {
|
||||
return 'Webhook'
|
||||
case 'telegram':
|
||||
return 'Telegram'
|
||||
case 'sms':
|
||||
return 'SMS Webhook'
|
||||
default:
|
||||
return type
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ export function AppLayout() {
|
||||
<Divider />
|
||||
<Space direction="vertical" size="medium" style={{ width: '100%' }}>
|
||||
<Typography.Title heading={6} style={{ margin: 0 }}>邮件 / 短信 OTP</Typography.Title>
|
||||
<Alert type="info" content="邮件 OTP 使用已启用的 Email 通知配置发送;短信 OTP 使用 SMS Webhook 通知配置发送。" />
|
||||
<Alert type="info" content="邮件 OTP 使用已启用的 Email 通知配置发送;短信 OTP 使用 Webhook 通知配置发送,payload 会包含 phone/code/purpose 字段。" />
|
||||
<Space wrap>
|
||||
<Tag color={user?.emailOtpEnabled ? 'green' : 'gray'} bordered>邮件 OTP {user?.emailOtpEnabled ? '已启用' : '未启用'}</Tag>
|
||||
<Tag color={user?.smsOtpEnabled ? 'green' : 'gray'} bordered>短信 OTP {user?.smsOtpEnabled ? '已启用' : '未启用'}</Tag>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type NotificationType = 'email' | 'webhook' | 'telegram' | 'sms'
|
||||
export type NotificationType = 'email' | 'webhook' | 'telegram'
|
||||
export type NotificationFieldType = 'input' | 'password' | 'number' | 'textarea'
|
||||
|
||||
export interface NotificationSummary {
|
||||
|
||||
Reference in New Issue
Block a user