功能添加
This commit is contained in:
@@ -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 模式下,跳过标记已读步骤");
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user