feat: implement Telegram multi-channel logging and enhance admin UI/UX guidelines
TaxBaik CI/CD / build-and-deploy (push) Successful in 49s
TaxBaik CI/CD / build-and-deploy (push) Successful in 49s
Telegram Logging Enhancements:
- Support multi-channel notifications (inquiry: -5434691215, system: -5585148480)
- New methods: SendInquiryNotificationAsync, SendSystemNotificationAsync
- Dynamic chat ID routing based on notification type
- Backward compatible with existing default ChatId configuration
Admin UI/UX Improvements (CLAUDE.md 10.5):
- Enter key focus transition between form fields
- Auto-submit on last field (with validation)
- Tab key equivalent with explicit input intent
- Applied to all admin management pages
Dorsum ERP Integration Guide (CLAUDE.md 10.6):
- Clear role definition: Dorsum (tax processing) vs TaxBaik (CRM/customer management)
- Elimination of data duplication principles
- Unique TaxBaik features (contract tracking, revenue management, CRM activities)
- Data ownership matrix (who owns what data)
- Future Dorsum API sync strategy (webhook/polling)
Guidelines Updates:
- Form field Enter key handling pattern
- Multi-tenant company management alignment
- API-first architecture reinforcement
Build Status: ✅ Success (0 errors, 3 warnings)
This commit is contained in:
@@ -11,6 +11,8 @@ public interface ITelegramNotificationService
|
||||
Task SendMessageAsync(string message, CancellationToken ct = default);
|
||||
Task SendErrorAsync(string title, string details, CancellationToken ct = default);
|
||||
Task SendInfoAsync(string title, string message, CancellationToken ct = default);
|
||||
Task SendInquiryNotificationAsync(string message, CancellationToken ct = default);
|
||||
Task SendSystemNotificationAsync(string message, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
public class TelegramNotificationService : ITelegramNotificationService
|
||||
@@ -18,7 +20,9 @@ public class TelegramNotificationService : ITelegramNotificationService
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly ILogger<TelegramNotificationService> _logger;
|
||||
private readonly string _botToken;
|
||||
private readonly string _chatId;
|
||||
private readonly string _defaultChatId;
|
||||
private readonly string _inquiryChatId;
|
||||
private readonly string _systemChatId;
|
||||
private const string TelegramApiUrl = "https://api.telegram.org";
|
||||
|
||||
public TelegramNotificationService(
|
||||
@@ -29,23 +33,42 @@ public class TelegramNotificationService : ITelegramNotificationService
|
||||
_httpClient = httpClient;
|
||||
_logger = logger;
|
||||
_botToken = config["Telegram:BotToken"] ?? "";
|
||||
_chatId = config["Telegram:ChatId"] ?? "";
|
||||
_defaultChatId = config["Telegram:ChatId"] ?? "";
|
||||
_inquiryChatId = config["Telegram:InquiryChatId"] ?? "-5434691215";
|
||||
_systemChatId = config["Telegram:SystemChatId"] ?? "-5585148480";
|
||||
}
|
||||
|
||||
public async Task SendMessageAsync(string message, CancellationToken ct = default)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_botToken) || string.IsNullOrEmpty(_chatId))
|
||||
if (string.IsNullOrEmpty(_botToken) || string.IsNullOrEmpty(_defaultChatId))
|
||||
{
|
||||
_logger.LogWarning("Telegram credentials not configured");
|
||||
return;
|
||||
}
|
||||
|
||||
await SendToChat(_defaultChatId, message, ct);
|
||||
}
|
||||
|
||||
public async Task SendInquiryNotificationAsync(string message, CancellationToken ct = default) =>
|
||||
await SendToChat(_inquiryChatId, $"<b>📋 문의 사항</b>\n\n{message}", ct);
|
||||
|
||||
public async Task SendSystemNotificationAsync(string message, CancellationToken ct = default) =>
|
||||
await SendToChat(_systemChatId, $"<b>🔧 시스템 알림</b>\n\n{message}", ct);
|
||||
|
||||
private async Task SendToChat(string chatId, string message, CancellationToken ct)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_botToken) || string.IsNullOrEmpty(chatId))
|
||||
{
|
||||
_logger.LogWarning("Telegram credentials not configured for chatId {ChatId}", chatId);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var url = $"{TelegramApiUrl}/bot{_botToken}/sendMessage";
|
||||
var payload = new
|
||||
{
|
||||
chat_id = _chatId,
|
||||
chat_id = chatId,
|
||||
text = message,
|
||||
parse_mode = "HTML"
|
||||
};
|
||||
@@ -53,12 +76,12 @@ public class TelegramNotificationService : ITelegramNotificationService
|
||||
var response = await _httpClient.PostAsJsonAsync(url, payload, cancellationToken: ct);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
_logger.LogError("Failed to send Telegram message: {StatusCode}", response.StatusCode);
|
||||
_logger.LogError("Failed to send Telegram message to {ChatId}: {StatusCode}", chatId, response.StatusCode);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error sending Telegram message");
|
||||
_logger.LogError(ex, "Error sending Telegram message to {ChatId}", chatId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user