Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Content: author endpoints + server-side HTML sanitization (Phase 4.2)

Đang mở
#3 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
csharp, html, postgresql
Lĩnh vực
api, backend, security, testing

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ả

content

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 DbContext mapped 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 (see Members/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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CommunityPro/community-pro-api

Tất cả issue của CommunityPro/community-pro-api

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.