Contributors: org webhook receiver + ContributionEvent (Phase 5.1)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
调研方向
首先跟踪 Identity 模块的 webhook 处理,以及 tests/CommunityPro.Tests/Members/MembersTestHarness.cs 中的模式。在定义 Contributors 模块边界之前,检查 env.example 和入口点 IEndpointModule.MapEndpoints。完成的标准是接受有效签名,正确处理无效签名和未合并的关闭,并将重复的 delivery 或 repo/PR 重复视为 no-ops,同时使用 xUnit 覆盖包括竞态在内的测试。
由索引模型根据 Issue 内容生成。
描述
Scope
New CommunityPro.Contributors module (schema contributors): receive org-level GitHub webhooks and record merged PRs. Merged PRs are the main community metric.
Endpoint
POST /webhooks/github/org — validate X-Hub-Signature-256 HMAC with a separate org webhook secret (new env var; add to env.example). Handle pull_request events where action == "closed" && pull_request.merged == true.
Data model
public sealed class ContributionEvent
{
public Guid Id { get; set; }
public long GithubUserId { get; set; } // numeric id — the identity key (logins get renamed)
public string GithubLogin { get; set; } // display only, refresh freely
public string Repo { get; set; }
public long PrNumber { get; set; }
public DateTimeOffset MergedAt { get; set; }
}
Idempotency (non-negotiable)
GitHub redelivers. Record X-GitHub-Delivery GUIDs in a per-source delivery table with a unique-constraint insert as the guard — copy the Phase 1 practice-repo webhook pattern (see the Identity module's webhook handling). Also add a unique constraint on (Repo, PrNumber) as a second layer.
Error codes
webhooks.invalid_signature (401), replays → 200 no-op
Acceptance criteria
- Invalid/missing HMAC rejected; valid signature verified against raw body bytes
- Replayed delivery id is a no-op; duplicate repo+PR is a no-op
- Non-merge closes ignored
- xUnit coverage incl. signature validation and idempotency races
Conventions (project-wide, non-negotiable)
- .NET 9, records for immutable shapes, file-scoped namespaces, primary constructors where they read well. Minimal-API endpoints grouped per module via
IEndpointModule.MapEndpoints. Result<T>(SharedKernel) instead of exception-driven control flow. Endpoint results map failures to ProblemDetails with the stable error codes listed above — the frontend keys off them.- Module owns its EF Core
DbContextmapped to its own Postgres schema. Modules never reference each other's internals — cross-module needs go through a public contract interface or an in-process domain event (IEventPublisher). - All external calls (GitHub, Stripe, Brevo, Cloudinary, Meilisearch) behind interfaces owned by the consuming module.
- Every list endpoint paginated (offset is fine). xUnit tests in
tests/CommunityPro.Tests/<Module>/following the existing harness patterns (seeMembers/MembersTestHarness.cs).
- 主要语言
- C#
- 星标
- 0
- 派生
- 0
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
CommunityPro/community-pro-api 的其他 Issue
-
cross-cutting decision
难度 5/5 一周以上 新手友好度 35/100
-
cross-cutting
难度 4/5 3-5 天 新手友好度 58/100
-
admin
难度 5/5 一周以上 新手友好度 35/100
-
admin
难度 5/5 一周以上 新手友好度 35/100
-
sponsorship
难度 4/5 3-5 天 新手友好度 48/100
查看 CommunityPro/community-pro-api 的全部 Issue
相似的 Issue
-
enhancement needs-triage
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/microsoft-ui-reactor#1460 ·
维护者通常 1 天内回复
-
t/bug
难度 2/5 1-3 小时 新手友好度 75/100
dotnet/maui#39950 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
CommunityToolkit/Datasync#600 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
NimblePros/deviq-hugo#121 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
philterd/phileas-dotnet#188 ·