feat: Add mail test functionality

Adds a dialog to test email settings and integrates with the `/api/settings/test/email` API endpoint.
- Added a "Test Email" button to the Mail Settings tab.
- Implemented a dialog for entering the recipient email and selecting a template.
- Added UI elements for the dialog (input fields, radio buttons, and a send button).
- Updated `src/services/settingsService.ts` to include the test email API call.
- Added UI components for the dialog (using existing UI components).
- Updated `src/components/settings/general/MailSettingsTab.tsx` to include the test email functionality.
This commit is contained in:
Tola Leng
2025-06-05 21:06:48 +08:00
parent a88b356bf5
commit 039a832b79
6 changed files with 325 additions and 42 deletions
@@ -88,4 +88,4 @@ export async function sendSignalNotification(
});
return false;
}
}
}
@@ -20,9 +20,9 @@ export async function sendTelegramNotification(
enabled: config.enabled
}, null, 2));
// Use provided credentials if available, otherwise use config
const chatId = config.telegram_chat_id || "-10345353455465";
const botToken = config.bot_token || "7581526325:AAFZgmn9hz436ret3453454";
// Use provided credentials
const chatId = config.telegram_chat_id;
const botToken = config.bot_token;
if (!chatId || !botToken) {
console.error("Missing Telegram configuration - Chat ID:", chatId, "Bot token present:", !!botToken);
@@ -106,30 +106,4 @@ export async function sendTelegramNotification(
});
return false;
}
}
/**
* Test function to send a direct Telegram message
* without requiring configuration from the database
*/
export async function testSendTelegramMessage(
chatId: string = "-10345353455465",
botToken: string = "7581526325:AAFZgmn9hz436ret3453454",
message: string = "This is a test message from the monitoring system"
): Promise<boolean> {
console.log("====== DIRECT TELEGRAM TEST ======");
console.log(`Testing Telegram notification with chat ID: ${chatId}`);
// Create a minimal config with just the required fields
const testConfig: AlertConfiguration = {
service_id: "test",
notification_type: "telegram",
telegram_chat_id: chatId,
bot_token: botToken,
notify_name: "Test Direct Notification",
enabled: true
};
console.log("Sending test message with content:", message);
return await sendTelegramNotification(testConfig, message);
}
}