Skip to content

feat: dependency injection and comments threads - #418

Open
CodeVoyager wants to merge 6 commits into
masterfrom
feat/comments-ee-prep
Open

feat: dependency injection and comments threads#418
CodeVoyager wants to merge 6 commits into
masterfrom
feat/comments-ee-prep

Conversation

@CodeVoyager

@CodeVoyager CodeVoyager commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Inject CommentRepository as an optional last argument on admin and common comment services (defaulting to getCommentRepository(strapi)), so callers can swap the repository without changing service internals.
  • Split admin posting into two methods: postComment creates a top-level admin comment (threadOf: null, related is the content relation), and postCommentThread replies in an existing thread. The existing route POST /moderate/thread/:id/postComment now calls postCommentThread, so the HTTP path for thread replies is unchanged.
  • Expose blockNestedThreads on the admin service as a wrapper around modifiedNestedNestedComments.
  • Update admin/common service tests to pass a mock repository and cover the new post/thread split.

Test plan

  • Admin list, reports, thread details, approve, reject, update, and delete still work with the default repository (no injected repo).
  • Posting a moderator reply via POST /moderate/thread/:id/postComment still creates a child comment (threadOf = that id), not a top-level comment.
  • postComment (service) creates a top-level admin comment on the related entity.
  • Blocking a nested thread via blockNestedThreads updates descendant blockedThread flags.
  • Unit tests: admin.service, common.service, admin.controller.
  • Confirm findAllInHierarchy response shape: the “pagination on comments tree” commit only changed tests to expect { data, pagination }, but the service still returns an array. Either restore the old assertions or wrap the tree in { data, pagination } before merge.

@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.22642% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.33%. Comparing base (8384df8) to head (bfe78f1).

Files with missing lines Patch % Lines
server/src/services/admin/admin.service.ts 91.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #418      +/-   ##
==========================================
- Coverage   99.48%   99.33%   -0.15%     
==========================================
  Files          42       42              
  Lines        1353     1357       +4     
  Branches      316      336      +20     
==========================================
+ Hits         1346     1348       +2     
- Misses          7        9       +2     
Flag Coverage Δ
unittest 99.33% <96.22%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants