Skip to content

[需求] CLA邮件通知,能展示双语(中文+英文)-的开发实现-app-cla-server部分 - #533

Open
fly333sky wants to merge 2 commits into
reviewfrom
issue-2797-from-review
Open

fly333sky wants to merge 2 commits into
reviewfrom
issue-2797-from-review

Conversation

@fly333sky

Copy link
Copy Markdown
Contributor

背景

[需求] CLA邮件通知,能展示双语(中文+英文)(app-cla-server)· 开发流水线 · 开发预览阶段(代码已推 + 预览已部署 + UT 已补;门禁/对抗由 PR CI 异步跑)

改动内容

fix(app-cla-server): NormalizeLang 大小写不敏感,修复个人签署中文邮件渲染为英文

问题

review 指出:controllers/individual_signing.go:85 个人签署完成邮件直接用未经规范化的
原始请求值 info.CLALanguage 作为 Lang。签署流程对语言大小写不敏感地接受
(dp.NewLanguage → config.getLanguage 用 strings.ToLower 归一,"chinese"/"CHINESE"
均签署成功入库为 "Chinese"),但 emailtmpl.NormalizeLang 仅识别精确串
"Chinese"/"English"/"zh"/"en",对其余大小写变体一律兜底 en。

后果:客户端以小写或非规范大小写提交 cla_language=chinese 时,签署按中文成功落库,
完成通知邮件却渲染成英文,违反验收标准 1。

修复

采用 review 建议的方案 (b):把 emailtmpl.NormalizeLang 改为大小写不敏感
(switch strings.ToLower(v):chinese/zh→zh、english/en→en、其余→en),
从根上消除全部路径的大小写隐患。

NormalizeLang 是 genEmailMsg(template.go:120)的唯一语言归一入口,所有 21 类
邮件渲染均经此函数;watch/notify_corp_admin.go 的审计日志(line 267/479)也调用它。
因此只需改这一处,即覆盖全部发信路径(含 individual_signing),无需逐个 controller 改。

变更文件

  1. signing/infrastructure/emailtmpl/template.go

    • 新增 strings import
    • NormalizeLang:switch v → switch strings.ToLower(v),
      case 由 "Chinese"/"English" 改为 "chinese"/"english"
  2. signing/infrastructure/emailtmpl/template_test.go

    • TestNormalizeLang:修正原编码 buggy 行为的用例 {"chinese", langEN} → langZH
    • 新增大小写变体用例:CHINESE→zh、ChInEsE→zh、english→en、ZH→zh、EN→en

验证

  • go build ./... 通过
  • go vet ./signing/infrastructure/emailtmpl/... 通过
  • go test -cover ./signing/infrastructure/emailtmpl/... 全绿,覆盖率 91.4%

UT 补充

  • 文件:signing/infrastructure/emailtmpl/template_test.go
  • 覆盖场景:TestNormalizeLang 覆盖了大小写不敏感归一的全部分支——
    正常路径(Chinese/English/zh/en)、大小写变体(chinese/CHINESE/ChInEsE/english/ENGLISH/ZH/EN)、
    兜底路径(空串、未知值 xx)。

相关 Issue

resolve https://github.com/opensourceways/backlog/issues/2797

AI 使用声明

当前 PR 是否有 AI 参与:

@opensourceways-bot

Copy link
Copy Markdown
Contributor

Welcome To opensourceways Community

Hey @fly333sky , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands.

Contact Guide

If you have any questions, please contact the SIG: infratructure ,
and any of the maintainers: @GeorgeCao-hw, @TangJia025, @pkking, @zhongjun2 ,
and any of the committers: @JavaPythonAIForBAT, @TomNewChao, @Zherphy, @tfhddd, @yangwei999, @zhongjun2 .

@opensourceways-bot

Copy link
Copy Markdown
Contributor

CLA Signature Pass

fly333sky, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@opensourceways-bot

Copy link
Copy Markdown
Contributor
检查项 状态
敏感信息扫描 ✅
漏洞扫描 ✅
开源license合规扫描 ✅
开发阶段设计文档检查 ❌
流水线链接 点击跳转查看日志

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants