功能添加
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 20s
Docker Build & Deploy / Deploy to Production (push) Successful in 5s

This commit is contained in:
孙诚
2025-12-26 15:21:31 +08:00
parent 7dfb6a5902
commit cb11d80d1f
26 changed files with 2208 additions and 841 deletions

View File

@@ -195,7 +195,7 @@ public class EmailBackgroundService(
message.Subject,
message.Date.DateTime,
message.TextBody ?? message.HtmlBody ?? string.Empty
))
) || (DateTime.Now - message.Date.DateTime > TimeSpan.FromDays(3)))
{
#if DEBUG
logger.LogDebug("DEBUG 模式下,跳过标记已读步骤");

View File

@@ -29,24 +29,24 @@ public class EmailHandleService(
string body
)
{
var emailMessage = await SaveEmailAsync(from, subject, date, body);
if (emailMessage == null)
{
throw new InvalidOperationException("邮件保存失败,无法继续处理");
}
var filterForm = emailSettings.Value.FilterFromAddresses;
if (filterForm.Length == 0)
{
logger.LogWarning("未配置邮件过滤条件,跳过账单处理");
return true;
return false;
}
if (!filterForm.Any(f => from.Contains(f)))
{
logger.LogInformation("邮件不符合发件人过滤条件,跳过账单处理");
return true;
return false;
}
var emailMessage = await SaveEmailAsync(from, subject, date, body);
if (emailMessage == null)
{
throw new InvalidOperationException("邮件保存失败,无法继续处理");
}
var parsed = await ParseEmailBodyAsync(
@@ -161,7 +161,6 @@ public class EmailHandleService(
{
From = from,
Subject = subject,
ReceivedDate = date,
};
@@ -177,13 +176,15 @@ public class EmailHandleService(
try
{
var existsEmail = await emailRepo.ExistsAsync(from, subject, date, body);
var emailMd5 = emailEntity.ComputeBodyHash();
var existsEmail = await emailRepo.ExistsAsync(emailMd5);
if (existsEmail != null)
{
logger.LogInformation("检测到重复邮件,跳过入库:{From} | {Subject} | {Date}", from, subject, date);
return existsEmail;
}
emailEntity.Md5 = emailMd5;
var ok = await emailRepo.AddAsync(emailEntity);
if (ok)
{