Content: author endpoints + server-side HTML sanitization (Phase 4.2)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 56/100
Hướng nghiên cứu
Trước tiên, hãy kiểm tra các mẫu endpoint và workflow hiện có của mô-đun Content, sau đó kiểm tra entity Post và workflow từ dependency #2. Sử dụng test harness Members tại tests/CommunityPro.Tests/Members/MembersTestHarness.cs làm tham chiếu kiểm thử được chỉ định và thêm độ bao phủ xUnit cho từng endpoint, bao gồm cả các payload TipTap có tính thù địch. Công việc được xem là hoàn tất khi các tiêu chí về authorization, state, validation, sanitization, error-code và pagination được liệt kê đều đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Scope
Author-facing endpoints on the Content module. Any active member can write; authors can only touch their own posts.
| Method | Path | Auth | Notes |
|---|---|---|---|
| GET | /posts/mine |
active member | paginated, all statuses, author only |
| POST | /posts/mine |
active member | create draft |
| PUT | /posts/{id} |
active member | edit own Draft/Rejected post (autosave target — must be cheap) |
| POST | /posts/{id}/submit |
active member | Draft → Submitted |
Sanitization
On submit, produce ContentHtml from the TipTap payload server-side using HtmlSanitizer. Store both: ContentJson for re-editing, sanitized ContentHtml as the only thing public pages ever render. Never trust or render raw author HTML.
Validation
Title/excerpt length caps, tag whitelist + max count, cover image URL must be an allowed image host (see MemberProfileService.IsAllowedAvatarHttpsUrl for the pattern and host list).
Error codes
content.not_found, content.not_author, content.invalid_state, content.invalid_post
Dependencies
Blocked by #2 (Post entity + workflow).
Acceptance criteria
- Non-author gets
content.not_author(404-shaped, no existence leak, matching project convention) - Editing a Submitted/Published post fails with
content.invalid_state - Submit sanitizes: script tags, event handlers, javascript: URLs stripped (tests with hostile payloads)
- Pending (non-active) members are rejected by the policy
- xUnit coverage per endpoint
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).
- Ngôn ngữ chính
- C#
- Star
- 0
- Fork
- 0
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của CommunityPro/community-pro-api
-
cross-cutting decision
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
cross-cutting
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
-
admin
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
admin
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
sponsorship
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Tất cả issue của CommunityPro/community-pro-api
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
unoplatform/uno.check#591 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
weaviate/csharp-client#378 ·
-
agentic-workflows automated testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Azure-Samples/Legacy-Modernization-Agents#194 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area-encryption area-security p1-recommended technical-debt
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
V5: `asAllDay` parameter not working in `/feed/v5/calendar/sonarr.ics`Có thể đã có người làm @stevietv đã nhận hôm nay. Đang mởneeds-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày