fix(mail): 审核邮件按用户注册语言发送,统一服务器名前缀与 {server_name} 占位符 - #25
Open
qs5668 wants to merge 1 commit into
Open
Conversation
- 注册时记录用户界面语言(users.json / MySQL 新增 language 字段,存量表自动迁移)
- 审核结果邮件按用户注册语言发送,无记录的老用户回退到全局 language 配置
- 审核邮件标题改用 web_server_prefix 作为前缀,不再硬编码 [VerifyMC]
- 验证码邮件模板补齐 {server_name} 占位符替换,与审核模板能力一致
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题背景
实际部署 v1.8.0 时发现邮件通知存在 4 个相关问题:
1. 审核结果邮件语言与用户注册语言不符(主要问题)
用户用中文界面注册(收到的验证码邮件是中文),但管理员审核通过/拒绝后,收到的通知邮件却是英文的。
根因:
AdminUserHandler.sendReviewResult()和/vmc approve|reject命令都用ctx.getConfigManager().getLanguage()(服务器全局配置)决定邮件语言,而用户数据中没有存储注册时的界面语言。2. 审核邮件标题硬编码
[VerifyMC]前缀审核邮件标题为
[VerifyMC] Your whitelist application has been approved,使用的是插件名而不是web_server_prefix配置的服务器名。验证码邮件标题走email_subject配置项(可自定义),审核邮件却写死了,两者行为不一致。3. 验证码邮件模板不支持
{server_name}占位符MailService.sendCode()只替换{code},不替换{server_name};而sendReviewResultNotification()两者都替换。验证码模板作者无法引用服务器名。4. 默认验证码模板页脚硬编码插件名
verify_code_*.html页脚固定为"此邮件由 VerifyMC 自动发送",多服部署或换了服务器名时无法自定义。修复内容
RegistrationProcessingHandler→ 新增userDao.setUserLanguage());审核发信时优先读用户语言,无记录的老用户回退到全局language配置(完全向后兼容)web_server_prefix,zh/en 各自本地化{server_name}:sendCode()补齐占位符替换,与审核模板能力对齐UserDao接口新增setUserLanguage()FileUserDao:users.json 用户记录增加language字段MysqlUserDao:建表语句加language VARCHAR(8) NULL;存量表启动时自动ALTER TABLE迁移(与现有discord_id列迁移同一模式);查询结果带出language测试
Leaves 1.21.8 + 本补丁构建的 jar,三个测试用户(本地 SMTP 捕获邮件验证):
en<服务器名> Whitelist Application Approvedzh<服务器名> 白名单申请已通过<服务器名> 白名单申请已通过language配置)兼容性:users.json 老数据无
language字段时行为与修复前一致;Web 管理面板和/vmc命令两个审核入口行为统一。