fix: route sms otp through webhook notifier

This commit is contained in:
Awuqing
2026-04-25 22:09:26 +08:00
parent 6e7a884c64
commit 1e386e1205
8 changed files with 6 additions and 225 deletions

View File

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

View File

@@ -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
}