Refactor welcome message handling to UserService for Telegram channel updates
- Moved the welcome message logic from UserController to UserService to centralize user notification handling. - Improved error logging for message sending failures, ensuring better traceability of issues. - Enhanced user experience by maintaining the detailed setup information and friendly greeting in the welcome message.
This commit is contained in:
@@ -106,37 +106,6 @@ public class UserController : BaseController
|
||||
{
|
||||
var user = await GetUser();
|
||||
var updatedUser = await _userService.UpdateTelegramChannel(user, telegramChannel);
|
||||
|
||||
// Send welcome message to the newly configured telegram channel
|
||||
if (!string.IsNullOrEmpty(telegramChannel))
|
||||
{
|
||||
try
|
||||
{
|
||||
var welcomeMessage = $"🎉 **Welcome to Kaigen Notifications!**\n\n" +
|
||||
$"Hello {user.AgentName}! 👋\n\n" +
|
||||
$"Your Telegram channel has been successfully configured and you're now connected to the Kaigen notification system.\n\n" +
|
||||
$"📋 **Your Setup Details:**\n" +
|
||||
$"• 🎯 **Agent Name:** {user.AgentName}\n" +
|
||||
$"• 📡 **Channel ID:** {telegramChannel}\n" +
|
||||
$"• ⏰ **Connected:** {DateTime.UtcNow:MMM dd, yyyy • HH:mm:ss} UTC\n\n" +
|
||||
$"🔔 **What You'll Receive:**\n" +
|
||||
$"• 📈 Real-time position opens and closes\n" +
|
||||
$"• 💰 Trading activity updates\n" +
|
||||
$"• 🤖 Strategy and configuration changes\n" +
|
||||
$"• ⚠️ Important system alerts\n\n" +
|
||||
$"✨ **You're all set!** Start receiving your trading notifications right away. If you have any questions, feel free to reach out.\n\n" +
|
||||
$"Happy trading! 🚀";
|
||||
|
||||
await _webhookService.SendMessage(welcomeMessage, telegramChannel);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Log the error but don't fail the update operation
|
||||
Console.WriteLine(
|
||||
$"Failed to send welcome message to telegram channel {telegramChannel}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(updatedUser);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user