feat(wechat): Improve template message response handling with logging
All checks were successful
continuous-integration/drone/push Build is passing

- Add response content logging for debugging template message sends
- Handle empty response cases with explicit null check and warning log
- Replace ReadFromJsonAsync with manual deserialization for better error visibility
- Ensure service account template messages are properly validated before processing
This commit is contained in:
zpc 2026-03-29 20:37:30 +08:00
parent 3c53cddd0b
commit a74eee4dc8

View File

@ -452,7 +452,17 @@ public class WeChatService : IWeChatService
}
var response = await _httpClient.PostAsJsonAsync(url, requestBody);
var result = await response.Content.ReadFromJsonAsync<WeChatApiResponse>();
var responseContent = await response.Content.ReadAsStringAsync();
_logger.LogInformation("发送服务号模板消息响应: {Response}", responseContent);
if (string.IsNullOrWhiteSpace(responseContent))
{
_logger.LogWarning("发送服务号模板消息失败: 微信返回空响应");
return false;
}
var result = System.Text.Json.JsonSerializer.Deserialize<WeChatApiResponse>(responseContent);
if (result?.ErrCode != 0)
{