feat: enrich inquiry telegram alerts
TaxBaik Browser E2E / browser-e2e (push) Successful in 34s
TaxBaik CI/CD / build-and-deploy (push) Failing after 1m9s

This commit is contained in:
2026-06-27 16:10:58 +09:00
parent 620491fa9f
commit 4f2d5b1777
5 changed files with 19 additions and 8 deletions
@@ -59,7 +59,7 @@ public class InquiryServiceTests
private sealed class FakeInquiryNotificationService : IInquiryNotificationService
{
public Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, CancellationToken ct = default)
public Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, string? ipAddress, DateTime createdAtUtc, CancellationToken ct = default)
=> Task.CompletedTask;
public Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, CancellationToken ct = default)
@@ -2,6 +2,6 @@ namespace TaxBaik.Application.Services;
public interface IInquiryNotificationService
{
Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, CancellationToken ct = default);
Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, string? ipAddress, DateTime createdAtUtc, CancellationToken ct = default);
Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, CancellationToken ct = default);
}
@@ -35,7 +35,7 @@ public class InquiryService(IInquiryRepository repository, IInquiryNotificationS
};
var inquiryId = await repository.CreateAsync(inquiry, ct);
await notificationService.NotifyCreatedAsync(inquiryId, inquiry.Name, inquiry.Phone, inquiry.ServiceType, inquiry.Message, ct);
await notificationService.NotifyCreatedAsync(inquiryId, inquiry.Name, inquiry.Phone, inquiry.ServiceType, inquiry.Message, inquiry.IpAddress, inquiry.CreatedAt, ct);
return inquiryId;
}
@@ -2,7 +2,7 @@ namespace TaxBaik.Application.Services;
public sealed class NoopInquiryNotificationService : IInquiryNotificationService
{
public Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, CancellationToken ct = default)
public Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, string? ipAddress, DateTime createdAtUtc, CancellationToken ct = default)
=> Task.CompletedTask;
public Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, CancellationToken ct = default)
@@ -19,7 +19,7 @@ public class TelegramInquiryNotificationService : IInquiryNotificationService
_baseUrl = (_configuration["App:PublicBaseUrl"] ?? "http://178.104.200.7/taxbaik").TrimEnd('/');
}
public async Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, CancellationToken ct = default)
public async Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, string? ipAddress, DateTime createdAtUtc, CancellationToken ct = default)
{
var botToken = _configuration["Telegram:BotToken"];
var chatId = _configuration["Telegram:ChatId"];
@@ -28,12 +28,15 @@ public class TelegramInquiryNotificationService : IInquiryNotificationService
var adminLink = $"{_baseUrl}/admin/inquiries/{inquiryId}";
var summary = message.Length > 180 ? message[..180] + "..." : message;
var createdAtKst = createdAtUtc.AddHours(9);
var text = new StringBuilder()
.AppendLine("새 문의가 접수되었습니다.")
.AppendLine("🆕 새 문의가 접수되었습니다.")
.AppendLine()
.AppendLine($"제목: {serviceType}")
.AppendLine($"이름: {name}")
.AppendLine($"연락처: {phone}")
.AppendLine($"접수 시각: {createdAtKst:yyyy-MM-dd HH:mm:ss} KST")
.AppendLine($"IP: {(string.IsNullOrWhiteSpace(ipAddress) ? "-" : ipAddress)}")
.AppendLine()
.AppendLine("내용 요약:")
.AppendLine(summary)
@@ -71,12 +74,12 @@ public class TelegramInquiryNotificationService : IInquiryNotificationService
var adminLink = $"{_baseUrl}/admin/inquiries/{inquiryId}";
var text = new StringBuilder()
.AppendLine("문의 상태가 변경되었습니다.")
.AppendLine("✏️ 문의 상태가 변경되었습니다.")
.AppendLine()
.AppendLine($"제목: {serviceType}")
.AppendLine($"이름: {name}")
.AppendLine($"연락처: {phone}")
.AppendLine($"상태: {previousStatus} -> {newStatus}")
.AppendLine($"상태: {FormatStatus(previousStatus)} -> {FormatStatus(newStatus)}")
.AppendLine()
.AppendLine($"답변 링크: {adminLink}")
.ToString();
@@ -101,4 +104,12 @@ public class TelegramInquiryNotificationService : IInquiryNotificationService
_logger.LogWarning(ex, "텔레그램 상태 변경 알림 중 오류 발생");
}
}
private static string FormatStatus(string status) => status switch
{
"new" => "신규",
"contacted" => "연락함",
"completed" => "완료",
_ => status
};
}