diff --git a/src/Snap.Hutao.Server/Snap.Hutao.Server/Service/MailService.cs b/src/Snap.Hutao.Server/Snap.Hutao.Server/Service/MailService.cs index 7d28512..985a50c 100644 --- a/src/Snap.Hutao.Server/Snap.Hutao.Server/Service/MailService.cs +++ b/src/Snap.Hutao.Server/Snap.Hutao.Server/Service/MailService.cs @@ -20,109 +20,180 @@ public MailService(IHttpClientFactory httpClientFactory, AppOptions appOptions, mailerSecret = appOptions.MailerSecret; } - public Task SendRegistrationVerifyCodeAsync(string emailAddress, string code) + public Task SendRegistrationVerifyCodeAsync(string emailAddress, string code, string language = "CHS") { - logger.LogInformation("Send Registration Mail to [{Email}] with [{Code}]", emailAddress, code); + logger.LogInformation("Send Registration Mail to [{Email}] with [{Code}] in [{language}]", emailAddress, code, language); MailOptions options = new() { - Subject = "Snap Hutao 账号安全", + Subject = language == "CHS" + ? "Snap Hutao 通行证安全" + : "Snap Hutao Passport Security", Address = emailAddress, - Title = "感谢您注册 Snap Hutao 账号", - RawContent = $""" -

以下是您注册账号所需的验证码:

+ Title = language == "CHS" + ? "感谢您注册 Snap Hutao 通行证" + : "Thank you for registering Snap Hutao Passport", + RawContent = language == "CHS" + ? $""" +

以下是您注册通行证所需的验证码:

{code} -

如果您没有注册账号,请忽略此邮件,不会有任何事情发生。

+

如果您没有注册通行证,请忽略此邮件,不会有任何事情发生。

+ """ + : $""" +

Here is the verification code you need for registering your passport:

+ {code} +

If you did not register an passport, please ignore this email, nothing will happen.

""", - Footer = "DGP Studio | 胡桃开发团队", + Footer = language == "CHS" + ? "该邮件是 DGP Studio 系统自动发送的,请勿回复" + : "This email is automatically sent by the DGP Studio system, please do not reply", }; return SendMailAsync(options); } - public Task SendResetPasswordVerifyCodeAsync(string emailAddress, string code) + public Task SendResetPasswordVerifyCodeAsync(string emailAddress, string code, string language = "CHS") { logger.LogInformation("Send ResetPassword Mail to [{Email}] with [{Code}]", emailAddress, code); MailOptions options = new() { - Subject = "Snap Hutao 账号安全", + Subject = language == "CHS" + ? "Snap Hutao 通行证安全" + : "Snap Hutao Passport Security", Address = emailAddress, - Title = "您正在修改 Snap Hutao 账号密码", - RawContent = $""" + Title = language == "CHS" + ? "您正在修改 Snap Hutao 通行证密码" + : "You are changing your Snap Hutao passport password", + RawContent = language == "CHS" + ? $"""

以下是您修改密码所需的验证码:

{code}

如果您没有重置密码,请忽略此邮件,不会有任何事情发生。

+ """ + : $""" +

The following is the verification code you need to change your password:

+ {code} +

If you did not reset your password, please ignore this email, nothing will happen.

""", - Footer = "DGP Studio | 胡桃开发团队", + Footer = language == "CHS" + ? "该邮件是 DGP Studio 系统自动发送的,请勿回复" + : "This email is automatically sent by the DGP Studio system, please do not reply", }; return SendMailAsync(options); } - public Task SendCancelRegistrationVerifyCodeAsync(string emailAddress, string code) + public Task SendCancelRegistrationVerifyCodeAsync(string emailAddress, string code, string language = "CHS") { logger.LogInformation("Send CancelRegistration Mail to [{Email}] with [{Code}]", emailAddress, code); MailOptions options = new() { - Subject = "Snap Hutao 账号安全", + Subject = language == "CHS" + ? "Snap Hutao 通行证安全" + : "Snap Hutao Passport Security", Address = emailAddress, - Title = "您正在注销 Snap Hutao 账号", - RawContent = $""" -

以下是您注销账号所需的验证码:

+ Title = language == "CHS" + ? "您正在注销 Snap Hutao 通行证" + : "You are deleting your Snap Hutao Passport", + RawContent = language == "CHS" + ? $""" +

请注意:注销通行证的操作是不可逆的

+

以下是您注销通行证所需的验证码:

{code} -

如果您没有注销账号,请忽略此邮件,不会有任何事情发生。

+

如果您没有注销通行证,请忽略此邮件,不会有任何事情发生。

+ """ + : $""" +

Please note: The operation of delete your passport is not recoverable.

+

The following is the verification code you need to delete your passport:

+ {code} +

If you did not delete your passport, please ignore this email, nothing will happen.

""", - Footer = "DGP Studio | 胡桃开发团队", + Footer = language == "CHS" + ? "该邮件是 DGP Studio 系统自动发送的,请勿回复" + : "This email is automatically sent by the DGP Studio system, please do not reply", }; return SendMailAsync(options); } - public Task SendPurchaseGachaLogStorageServiceAsync(string emailAddress, string expireAt, string tradeNumber) + public Task SendPurchaseGachaLogStorageServiceAsync(string emailAddress, string expireAt, string tradeNumber, string language = "CHS") { logger.LogInformation("Send GachaLog Mail to [{Email}] with [{Number}]", emailAddress, tradeNumber); MailOptions options = new() { - Subject = "胡桃云服务", + Subject = language == "CHS" + ? "胡桃云服务" + : "Snap Hutao Cloud Service", Address = emailAddress, - Title = "感谢您购买 Snap Hutao 祈愿记录上传服务", - RawContent = $""" + Title = language == "CHS" + ? "感谢您购买 Snap Hutao 祈愿记录上传服务" + : "Thank you for purchasing Snap Hutao Wish Record Backup Service", + RawContent = language == "CHS" + ? $"""

服务有效期至

{expireAt}

请妥善保存此邮件,订单编号:{tradeNumber}

+ """ + : $""" +

The service is valid until

+ {expireAt} +

Please keep this email safe, order number: {tradeNumber}

""", - Footer = "DGP Studio | 胡桃开发团队", + Footer = language == "CHS" + ? "该邮件是 DGP Studio 系统自动发送的,请勿回复" + : "This email is automatically sent by the DGP Studio system, please do not reply", }; return SendMailAsync(options); } - public Task SendOpenSourceLicenseNotificationApprovalAsync(string emailAddress) + public Task SendOpenSourceLicenseNotificationApprovalAsync(string emailAddress, string language = "CHS") { MailOptions options = new() { - Subject = "胡桃开放平台", + Subject = language == "CHS" + ? "胡桃开放平台" + : "Snap Hutao Open Platform", Address = emailAddress, - Title = "胡桃开放平台开发者申请", - RawContent = $"{emailAddress},你的开发者许可申请已经通过", - Footer = "DGP Studio | 胡桃开发团队", + Title = language == "CHS" + ? "胡桃开放平台开发者申请" + : "Snap Hutao Open Platform Developer Application", + RawContent = language == "CHS" + ? $"{emailAddress},你的开发者许可申请已经通过" + : $"{emailAddress}, your developer license application has been approved", + Footer = language == "CHS" + ? "该邮件是 DGP Studio 系统自动发送的,请勿回复" + : "This email is automatically sent by the DGP Studio system, please do not reply", }; return SendMailAsync(options); } - public Task SendApproveOpenSourceLicenseNotificationAsync(string userName, string url, string code) + public Task SendApproveOpenSourceLicenseNotificationAsync(string userName, string url, string code, string language = "CHS") { MailOptions options = new() { - Subject = "胡桃开放平台", + Subject = + language == "CHS" + ? "胡桃开放平台" + : "Hutao Open Platform", Address = smtpOptions.DiagnosticEmailAddress, - Title = "胡桃开放平台开发者申请", - RawContent = $""" -

申请账号:{userName}

+ Title = language == "CHS" + ? "胡桃开放平台开发者申请" + : "Snap Hutao Open Platform Developer Application", + RawContent = language == "CHS" + ? $""" +

申请通行证:{userName}

维护网站:{url}

批准 + """ + : $""" +

Application passport: {userName}

+

Maintenance website: {url}

+ Approve """, - Footer = "DGP Studio | 胡桃开发团队", + Footer = language == "CHS" + ? "该邮件是 DGP Studio 系统自动发送的,请勿回复" + : "This email is automatically sent by the DGP Studio system, please do not reply", }; return SendMailAsync(options); @@ -136,89 +207,94 @@ private static string ComposeMailBody(MailOptions options) - DGP-Studio Mail Template + DGP Studio Mail Template +
- +
{{options.Title}}
{{options.RawContent}}
- """; }