feat(mono):Introduce service layer and add new comment_reactions ta…#1218
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors storage access into a dedicated service layer, introduces a new ConversationStorage for comments and reactions, and adds support for comment_reactions via a migration and new API endpoints.
- Introduce
ConversationStorageandIssueServiceto encapsulate conversation and reaction logic. - Refactor all
storage.services.*calls to use the newstorage.<resource>()helper methods. - Add new database migration for
reactionstable and expose a POST endpoint for adding comment reactions.
Reviewed Changes
Copilot reviewed 46 out of 46 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| monobean/src/core/mega_core.rs | Switch from .services.git_db_storage field to git_db_storage() method. |
| mono/src/server/https_server.rs | Add CONV_TAG constant for conversation endpoints. |
| mono/src/api/mr/mr_router.rs | Update MR routes to use conv_stg() instead of issue_stg(). |
| mono/src/api/mr/mod.rs | Clean up imports and move SaveCommentRequest to conversation module. |
| mono/src/api/mod.rs | Add conversation submodule and conv_stg() helper. |
| mono/src/api/label/mod.rs | Introduce LabelUpdatePayload in label module. |
| mono/src/api/issue/mod.rs | Rename IssueDetail to IssueDetailRes and map new fields. |
| mono/src/api/issue/issue_router.rs | Update issue routes to use IssueService and conv_stg(). |
| mono/src/api/conversation/mod.rs | Add conversation models, reaction item, and SaveCommentRequest. |
| mono/src/api/conversation/conv_router.rs | Add POST /comments/{comment_id}/reactions endpoint. |
| mono/src/api/api_router.rs | Merge conv_router into main API router. |
| mono/src/api/api_common/model.rs | Remove duplicated LabelUpdatePayload. |
| mono/src/api/api_common/label_assignee.rs | Emit conversation records when labels/assignees change. |
| jupiter/src/tests.rs | Update test storage setup to include ConversationStorage and IssueService. |
| jupiter/src/storage/stg_common/mod.rs | Clean up imports for common models. |
| jupiter/src/storage/stg_common/item.rs | Import ItemKind from new model path. |
| jupiter/src/storage/mr_storage.rs | Import ListParams and ItemDetails from new model path. |
| jupiter/src/storage/mod.rs | Rename Service to AppService, add conversation_storage. |
| jupiter/src/storage/issue_storage.rs | Remove embedded add_conversation methods in issue storage. |
| jupiter/src/storage/conversation_storage.rs | New ConversationStorage implementation. |
| jupiter/src/service/mod.rs | Create IssueService struct. |
| jupiter/src/service/issue_service.rs | Implement get_issue_details combining labels and reactions. |
| jupiter/src/model/issue_dto.rs | Define IssueDetails and ConvWithReactions DTOs. |
| jupiter/src/model/common.rs | Update LabelAssigneeParams to drop unused fields. |
| jupiter/src/migration/m20250710_073119_create_reactions.rs | Add migration to create reactions table. |
| jupiter/callisto/src/reactions.rs | Add generated SeaORM entity for reactions table. |
| jupiter/callisto/src/prelude.rs | Export Reactions entity. |
| jupiter/callisto/src/entity_ext/reactions.rs | Add helper to create new reactions::Model. |
| gemini/src/util.rs | Switch .services.git_db_storage to .git_db_storage(). |
| gemini/src/p2p/client.rs | Switch to new storage helper methods for git DB. |
| context/src/lib.rs | Switch to storage.mono_storage() call. |
| ceres/src/protocol/mod.rs | Use git_db_storage() helper. |
| ceres/src/pack/monorepo.rs | Use new storage helpers instead of .services. |
| ceres/src/pack/import_repo.rs | Switch import pack to use storage helper methods. |
| ceres/src/api_service/mono_api_service.rs | Switch mono API service to use helper methods. |
| ceres/src/api_service/mod.rs | Update raw DB access to use helper. |
| ceres/src/api_service/import_api_service.rs | Update import API to use helper methods. |
| aries/src/service/api/nostr_router.rs | Switch relay storage to use .relay_storage() helper. |
Comments suppressed due to low confidence (5)
mono/src/api/conversation/mod.rs:36
- [nitpick] The field
viewer_reaction_idmay not align with the underlyingpublic_idin the reactions model; consider renaming topublic_idfor clarity.
pub viewer_reaction_id: String,
mono/src/api/conversation/mod.rs:56
- [nitpick] The field name
comment_typeis ambiguous; consider renaming tosubject_typeorreaction_typeto better convey its role.
pub comment_type: String,
mono/src/api/conversation/conv_router.rs:15
- [nitpick] Currently only a POST endpoint for adding reactions is provided; consider adding a GET endpoint to retrieve reactions for a comment to complete the API.
OpenApiRouter::new().nest(
jupiter/src/tests.rs:11
- Consider adding unit or integration tests for the new conversation and reactions functionality, ensuring that
ConversationStorageandIssueService::get_issue_detailsbehave as expected.
use crate::service::IssueService;
mono/src/api/conversation/mod.rs:1
- [nitpick] Consider adding module‐level documentation explaining the purpose of the conversation models and conversions to improve maintainability.
use serde::{Deserialize, Serialize};
| impl From<reactions::Model> for ConversationItem { | ||
| fn from(_: reactions::Model) -> Self { | ||
| todo!() |
There was a problem hiding this comment.
This From implementation maps reactions::Model to ConversationItem, but it should convert to ReactionItem. Consider implementing impl From<reactions::Model> for ReactionItem and adjusting the conversion logic accordingly.
| impl From<reactions::Model> for ConversationItem { | |
| fn from(_: reactions::Model) -> Self { | |
| todo!() | |
| // Implement conversion from reactions::Model to ReactionItem | |
| impl From<reactions::Model> for ReactionItem { | |
| fn from(value: reactions::Model) -> Self { | |
| Self { | |
| viewer_reaction_id: value.viewer_reaction_id, | |
| emoji: value.emoji, | |
| tooltip: value.tooltip, | |
| reactions_count: value.reactions_count, | |
| custom_content: value.custom_content.unwrap_or_default(), | |
| } |
| fn from(_: reactions::Model) -> Self { | ||
| todo!() |
There was a problem hiding this comment.
The conversion for reactions::Model is unimplemented (todo!()). Please implement mapping fields to ReactionItem or remove the stub if it's not needed.
| fn from(_: reactions::Model) -> Self { | |
| todo!() | |
| fn from(model: reactions::Model) -> Self { | |
| Self { | |
| id: model.id, | |
| username: model.username, | |
| conv_type: model.conv_type, | |
| comment: model.comment, | |
| created_at: model.created_at.and_utc().timestamp(), | |
| updated_at: model.updated_at.and_utc().timestamp(), | |
| grouped_reactions: model.reactions.into_iter().map(|reaction| ReactionItem { | |
| viewer_reaction_id: reaction.viewer_reaction_id, | |
| emoji: reaction.emoji, | |
| tooltip: reaction.tooltip, | |
| reactions_count: reaction.reactions_count, | |
| custom_content: reaction.custom_content, | |
| }).collect(), | |
| } |
…ble.