From 6af9221fab824d0c4c1cdab2ca72f621a7f066b0 Mon Sep 17 00:00:00 2001 From: kjh2064 Date: Sat, 27 Jun 2026 22:29:08 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=AC=B8=EC=9D=98=20=ED=8F=BC=20?= =?UTF-8?q?=EC=A0=9C=EC=B6=9C=EA=B3=BC=20=ED=85=94=EB=A0=88=EA=B7=B8?= =?UTF-8?q?=EB=9E=A8=20=EC=B6=94=EC=A0=81=20=EB=A1=9C=EA=B7=B8=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TaxBaik.Web/Pages/Contact.cshtml | 1 + .../TelegramInquiryNotificationService.cs | 33 ++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/TaxBaik.Web/Pages/Contact.cshtml b/TaxBaik.Web/Pages/Contact.cshtml index a4fc1b6..c903eec 100644 --- a/TaxBaik.Web/Pages/Contact.cshtml +++ b/TaxBaik.Web/Pages/Contact.cshtml @@ -16,6 +16,7 @@ }
+ @Html.AntiForgeryToken()
diff --git a/TaxBaik.Web/Services/TelegramInquiryNotificationService.cs b/TaxBaik.Web/Services/TelegramInquiryNotificationService.cs index 0dfd011..ced8bac 100644 --- a/TaxBaik.Web/Services/TelegramInquiryNotificationService.cs +++ b/TaxBaik.Web/Services/TelegramInquiryNotificationService.cs @@ -1,5 +1,6 @@ using System.Net.Http.Json; using System.Text; +using System.Text.Json; using TaxBaik.Application.Services; namespace TaxBaik.Web.Services; @@ -60,13 +61,14 @@ public class TelegramInquiryNotificationService : IInquiryNotificationService try { var response = await client.PostAsJsonAsync(url, payload, ct); + var responseBody = await response.Content.ReadAsStringAsync(ct); if (!response.IsSuccessStatusCode) { - _logger.LogWarning("텔레그램 알림 전송 실패: {StatusCode}", response.StatusCode); + _logger.LogWarning("텔레그램 알림 전송 실패: {StatusCode} {ResponseBody}", response.StatusCode, Truncate(responseBody)); } else { - _logger.LogInformation("텔레그램 새 문의 알림 전송 성공: #{InquiryId}", inquiryId); + _logger.LogInformation("텔레그램 새 문의 알림 전송 성공: #{InquiryId}, message_id={MessageId}", inquiryId, TryGetMessageId(responseBody)); } } catch (Exception ex) @@ -111,13 +113,14 @@ public class TelegramInquiryNotificationService : IInquiryNotificationService try { var response = await client.PostAsJsonAsync(url, payload, ct); + var responseBody = await response.Content.ReadAsStringAsync(ct); if (!response.IsSuccessStatusCode) { - _logger.LogWarning("텔레그램 상태 변경 알림 실패: {StatusCode}", response.StatusCode); + _logger.LogWarning("텔레그램 상태 변경 알림 실패: {StatusCode} {ResponseBody}", response.StatusCode, Truncate(responseBody)); } else { - _logger.LogInformation("텔레그램 상태 변경 알림 전송 성공: #{InquiryId}", inquiryId); + _logger.LogInformation("텔레그램 상태 변경 알림 전송 성공: #{InquiryId}, message_id={MessageId}", inquiryId, TryGetMessageId(responseBody)); } } catch (Exception ex) @@ -133,4 +136,26 @@ public class TelegramInquiryNotificationService : IInquiryNotificationService "completed" => "완료", _ => status }; + + private static string TryGetMessageId(string responseBody) + { + try + { + using var document = JsonDocument.Parse(responseBody); + if (document.RootElement.TryGetProperty("result", out var result) + && result.TryGetProperty("message_id", out var messageId)) + { + return messageId.ToString(); + } + } + catch (JsonException) + { + return "unknown"; + } + + return "unknown"; + } + + private static string Truncate(string value) + => value.Length <= 500 ? value : value[..500] + "..."; }