添加收件人信息
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 9s
Docker Build & Deploy / Deploy to Production (push) Has been skipped

This commit is contained in:
2025-12-27 16:54:08 +08:00
parent e68aef6ba1
commit bb5b2fae1e
6 changed files with 23 additions and 3 deletions

View File

@@ -32,6 +32,8 @@ public class EmailMessage : BaseEntity
/// </summary> /// </summary>
public DateTime ReceivedDate { get; set; } public DateTime ReceivedDate { get; set; }
public string To { get; set; } = string.Empty;
public string Md5 { get; set; } = string.Empty; public string Md5 { get; set; } = string.Empty;
public string ComputeBodyHash() public string ComputeBodyHash()

View File

@@ -191,6 +191,7 @@ public class EmailBackgroundService(
logger.LogDebug("邮件内容预览: {Preview}", GetEmailBodyPreview(message)); logger.LogDebug("邮件内容预览: {Preview}", GetEmailBodyPreview(message));
if (await emailHandleService.HandleEmailAsync( if (await emailHandleService.HandleEmailAsync(
email,
message.From.ToString(), message.From.ToString(),
message.Subject, message.Subject,
message.Date.DateTime, message.Date.DateTime,

View File

@@ -5,6 +5,7 @@ namespace Service;
public interface IEmailHandleService public interface IEmailHandleService
{ {
Task<bool> HandleEmailAsync( Task<bool> HandleEmailAsync(
string to,
string from, string from,
string subject, string subject,
DateTime date, DateTime date,
@@ -23,6 +24,7 @@ public class EmailHandleService(
) : IEmailHandleService ) : IEmailHandleService
{ {
public async Task<bool> HandleEmailAsync( public async Task<bool> HandleEmailAsync(
string to,
string from, string from,
string subject, string subject,
DateTime date, DateTime date,
@@ -42,7 +44,7 @@ public class EmailHandleService(
return false; return false;
} }
var emailMessage = await SaveEmailAsync(from, subject, date, body); var emailMessage = await SaveEmailAsync(to, from, subject, date, body);
if (emailMessage == null) if (emailMessage == null)
{ {
@@ -151,6 +153,7 @@ public class EmailHandleService(
} }
private async Task<EmailMessage?> SaveEmailAsync( private async Task<EmailMessage?> SaveEmailAsync(
string to,
string from, string from,
string subject, string subject,
DateTime date, DateTime date,
@@ -185,6 +188,9 @@ public class EmailHandleService(
} }
emailEntity.Md5 = emailMd5; emailEntity.Md5 = emailMd5;
var toName = emailSettings.Value.SmtpList
.FirstOrDefault(s => s.Email == to)?.Name ?? "";
emailEntity.To = string.IsNullOrEmpty(toName) ? to : $"{toName} <{to}>";
var ok = await emailRepo.AddAsync(emailEntity); var ok = await emailRepo.AddAsync(emailEntity);
if (ok) if (ok)
{ {

View File

@@ -35,7 +35,7 @@
> >
<van-cell <van-cell
:title="email.subject" :title="email.subject"
:label="`来自: ${email.from}`" :label="`来自: ${email.from}\n收件: ${email.toName || email.to || '未知'}`"
is-link is-link
@click="viewDetail(email)" @click="viewDetail(email)"
> >

View File

@@ -19,6 +19,8 @@ public class EmailMessageDto
/// </summary> /// </summary>
public int TransactionCount { get; set; } public int TransactionCount { get; set; }
public string ToName { get; set; } = string.Empty;
/// <summary> /// <summary>
/// 从实体转换为DTO /// 从实体转换为DTO
/// </summary> /// </summary>
@@ -34,7 +36,8 @@ public class EmailMessageDto
ReceivedDate = entity.ReceivedDate, ReceivedDate = entity.ReceivedDate,
CreateTime = entity.CreateTime, CreateTime = entity.CreateTime,
UpdateTime = entity.UpdateTime, UpdateTime = entity.UpdateTime,
TransactionCount = transactionCount TransactionCount = transactionCount,
ToName = entity.To?.Split('<').FirstOrDefault()?.Trim() ?? "未知"
}; };
} }
} }

View File

@@ -42,6 +42,14 @@
"ImapHost": "imap.qq.com", "ImapHost": "imap.qq.com",
"ImapPort": 993, "ImapPort": 993,
"UseSsl": true "UseSsl": true
},
{
"Name": "SYE",
"Email": "1390853363@qq.com",
"Password": "bmoumfqeyopribec",
"ImapHost": "imap.qq.com",
"ImapPort": 993,
"UseSsl": true
} }
], ],
"FilterFromAddresses": [ "FilterFromAddresses": [