feat(server): comment service and resolver
close CLOUD-227
PR Dependency Tree
-
PR #12760
-
PR #12761 👈
- PR #12795
-
PR #12761 👈
This tree was auto-generated by Charcoal
Walkthrough
This change introduces a comprehensive comment and reply system to the backend and GraphQL API. It includes new types, resolvers, services, permission roles (including "Commenter"), attachment upload functionality, error handling, and extensive tests. The update also extends the GraphQL schema and frontend i18n resources to fully support comment-related operations and permissions.
Changes
| File(s) / Path(s) | Change Summary |
|---|---|
| .../src/core/comment/{index.ts, resolver.ts, service.ts, types.ts} | Added full comment/reply module: NestJS module, GraphQL resolver, service logic, and GraphQL types/inputs. |
| .../src/core/comment/tests/service.spec.ts, .../snapshots/service.spec.ts.md | Added comprehensive unit tests and snapshots for comment/reply service logic. |
| .../src/tests/e2e/comment/resolver.spec.ts | Added end-to-end tests for comment/reply GraphQL resolvers and attachment upload. |
| .../src/base/graphql/pagination.ts, .../tests/pagination.spec.ts, .../snapshots/pagination.spec.ts.md | Added/extended pagination utilities and tests for custom cursor encoding/decoding. |
| .../src/base/utils/stream.ts | Added utility function readableToBuffer for stream-to-buffer conversion. |
| .../src/base/error/def.ts, .../src/base/error/errors.gen.ts | Added new error type/class for comment attachment quota exceeded. |
| .../src/app.module.ts | Registered CommentModule for GraphQL flavor. |
| .../src/core/permission/types.ts, .../src/core/permission/tests/snapshots/actions.spec.ts.md | Added comment-related actions/roles, including new Commenter role and permissions. |
| .../src/models/common/role.ts | Added Commenter to DocRole enum. |
| .../src/models/user.ts | Optimized user ID collection in getPublicUsersMap method. |
| .../src/schema.gql, .../common/graphql/src/schema.ts | Extended GraphQL schema for comment/reply types, permissions, and mutations. |
| .../common/graphql/src/graphql/comment-*.gql, .../common/graphql/src/graphql/index.ts | Added GraphQL queries/mutations for comment/reply CRUD, listing, attachment upload, and changes. |
| .../src/tests/e2e/create-app.ts | Increased max upload file size from 10MB to 100MB. |
| .../frontend/i18n/src/i18n.gen.ts, .../frontend/i18n/src/resources/en.json | Added i18n key and message for comment attachment quota exceeded error. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant GraphQL_API
participant CommentResolver
participant CommentService
participant PermissionService
participant StorageService
User->>GraphQL_API: Mutation (createComment / createReply / update / delete / resolve)
GraphQL_API->>CommentResolver: Call resolver method
CommentResolver->>PermissionService: Check permissions
PermissionService-->>CommentResolver: Permission result
CommentResolver->>CommentService: Perform operation (CRUD)
CommentService-->>CommentResolver: Result (comment/reply object or status)
CommentResolver-->>GraphQL_API: Return result
GraphQL_API-->>User: Response
User->>GraphQL_API: Mutation (uploadCommentAttachment)
GraphQL_API->>CommentResolver: uploadCommentAttachment
CommentResolver->>PermissionService: Check permissions
PermissionService-->>CommentResolver: Permission result
CommentResolver->>StorageService: Store attachment (size validation)
StorageService-->>CommentResolver: Attachment URL or error
CommentResolver-->>GraphQL_API: Return URL or error
GraphQL_API-->>User: Response
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Implement full comment service with CRUD, reply, permission checks, and listing (CLOUD-227) | ✅ | |
| Allow independent upload of attachments associated with a document (CLOUD-230) | ✅ |
Assessment against linked issues: Out-of-scope changes
| Code Change | Explanation |
|---|---|
| Increased max upload file size from 10MB to 100MB (packages/backend/server/src/tests/e2e/create-app.ts) | This change is not described in the linked issues and may be unrelated to comment features. |
Possibly related PRs
- #12760: Implements foundational comment/reply data models and schema, which this PR builds upon for full resolver/service integration.
- #12909: Introduces the comment-attachment database model and CRUD logic, directly supporting this PR’s attachment upload functionality.
Suggested reviewers
- darkskygit
- forehalo
Poem
In the land of code, a comment was born,
With replies and roles, permissions adorn.
Attachments now fly, with quota in sight,
"Commenter" joins, making things right.
Through GraphQL fields, the feedback flows—
A rabbit hops by, and everyone knows:
Collaboration grows! 🐇✨
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>, please review it. -
Explain this complex logic. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai explain this code block. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase. -
@coderabbitai read src/utils.ts and explain its main purpose. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format. -
@coderabbitai help me debug CodeRabbit configuration file.
-
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai generate docstringsto generate docstrings for this PR. -
@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Codecov Report
Attention: Patch coverage is 95.25032% with 37 lines in your changes missing coverage. Please review.
Project coverage is 56.56%. Comparing base (
e8bc8f2) to head (0b28255). Report is 7 commits behind head on canary.
Additional details and impacted files
@@ Coverage Diff @@
## canary #12761 +/- ##
==========================================
- Coverage 56.78% 56.56% -0.23%
==========================================
Files 2677 2681 +4
Lines 129019 129791 +772
Branches 20288 20288
==========================================
+ Hits 73269 73410 +141
- Misses 53584 54215 +631
Partials 2166 2166
| Flag | Coverage Δ | |
|---|---|---|
| server-test | 78.96% <95.25%> (-0.82%) |
:arrow_down: |
| unittest | 31.89% <ø> (-0.01%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.