[缺陷] cla的协议变更后,自动给开发者发送邮件通知的行为,需要加审计日志-的开发实现-app-cla-server部分#504
Open
fly333sky wants to merge 1 commit into
Open
[缺陷] cla的协议变更后,自动给开发者发送邮件通知的行为,需要加审计日志-的开发实现-app-cla-server部分#504fly333sky wants to merge 1 commit into
fly333sky wants to merge 1 commit into
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Welcome To opensourceways CommunityHey @fly333sky , thanks for your contribution to the community. Bot Usage ManualI'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 GuideIf you have any questions, please contact the SIG: infratructure , |
CLA Signature Passfly333sky, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
|
|||||||||||||||
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.
背景
[缺陷] cla的协议变更后,自动给开发者发送邮件通知的行为,需要加审计日志(app-cla-server)· 开发流水线 · 开发预览阶段(代码已推 + 预览已部署 + UT 已补;门禁/对抗由 PR CI 异步跑)
改动内容
feat(app-cla-server): 为 CLA 协议变更邮件通知补充审计日志
改动概述
修复 backlog#1483:CLA 协议变更后自动给开发者/管理员发送邮件通知的行为此前无任何日志记录。
在 app-cla-server 的「watch 通知 → worker 发信」链路上补齐结构化审计日志,记录 4W(收件人/时间戳/link_id+社区/CLA 变更与邮件主题/发送结果),便于审计追溯与问题排查。不引入新依赖、不新增对外接口、不改发信数据流与重试/退避策略。
生产代码改动(子仓 app-cla-server)
signing/watch/notify_corp_admin.gohandleSendEmail(企业 CLA → 通知 corp admin):在SendSimpleMessage之后新增意图审计日志[audit] cla_notify_email: scene=corp, link_id, org, corp_signing_id, recipient, from, subject, new_cla_id, signed_cla_id, notify_count。handleSendIndividualEmail(个人 CLA → 通知签署者):新增意图审计日志[audit] cla_notify_email: scene=individual, ...。worker/worker.gotryToSendEmail返回值由无改为bool(成功 true;重试 10 次耗尽或被 stop 为 false),原 10 次 ×1 分钟退避语义不变。SendSimpleMessage据返回值补结果审计日志:成功logs.Info("[audit] email_result: outcome=sent, ..."),失败logs.Error("[audit] email_result: outcome=failed, ..."),覆盖所有走 SendSimpleMessage 的邮件。GenCLAPDFForCorporationAndSendIt忽略新返回值,保持原行为(设计要求)。SetEmailWorker(返回还原函数),用于测试注入假 worker。单元测试(本轮新增)
worker/worker_test.go(新文件):TestTryToSendEmailSuccess(action 成功→true、仅调用一次)TestTryToSendEmailFailureReturnsFalse(action 持续失败→false,关闭 stop 避免等待 9 分钟)TestSendSimpleMessageSuccess(注册假 emailservice 成功,覆盖 outcome=sent 分支)TestSendSimpleMessageFailure(假 emailservice 失败 + Shutdown 关 stop,覆盖 outcome=failed 分支)signing/watch/main_test.go(新文件):TestMain切到模块根并emailtmpl.Init(),供依赖模板渲染的用例使用。signing/watch/notify_corp_admin_test.go(追加):fakeEmailWorker(实现worker.IEmailWorker,记录发信调用)TestHandleSendEmailAuditLogCorp(注入假 worker,验证企业通知审计日志路径被走到、不 panic、收件人/主题正确)TestHandleSendIndividualEmailAuditLogIndividual(同上,个人通知)验证结果
go build ./...通过;go vet ./worker/... ./signing/watch/...通过。go test -race ./worker/...全绿;本次新增 watch 用例全绿(两条[audit] cla_notify_email日志均已实际输出)。tryToSendEmail86.7%、SendSimpleMessage92.9%、handleSendEmail86.7%、handleSendIndividualEmail85.7%,均 ≥ 80%。备注(非本次范围)
signing/watch/config_test.go::TestNotifyAdminConfigSetDefault在本次改动前即已失败(git stash验证:config 间隔默认值 86400 vs 测试期望 1200),属既有遗留、与本需求审计日志无关,按「不改无关」未处理。相关 Issue
resolve https://github.com/opensourceways/backlog/issues/1483
AI 使用声明
当前 PR 是否有 AI 参与:
/ai-develop-preview