Skip to content

feat(mono):Introduce service layer and add new comment_reactions ta…#1218

Merged
genedna merged 2 commits into
gitmono-dev:mainfrom
benjamin-747:main
Jul 12, 2025
Merged

feat(mono):Introduce service layer and add new comment_reactions ta…#1218
genedna merged 2 commits into
gitmono-dev:mainfrom
benjamin-747:main

Conversation

@benjamin-747

Copy link
Copy Markdown
Collaborator

…ble.

@vercel

vercel Bot commented Jul 11, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mega ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 12, 2025 2:05pm

This comment was marked as outdated.

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ConversationStorage and IssueService to encapsulate conversation and reaction logic.
  • Refactor all storage.services.* calls to use the new storage.<resource>() helper methods.
  • Add new database migration for reactions table 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_id may not align with the underlying public_id in the reactions model; consider renaming to public_id for clarity.
    pub viewer_reaction_id: String,

mono/src/api/conversation/mod.rs:56

  • [nitpick] The field name comment_type is ambiguous; consider renaming to subject_type or reaction_type to 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 ConversationStorage and IssueService::get_issue_details behave 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};

Comment on lines +42 to +44
impl From<reactions::Model> for ConversationItem {
fn from(_: reactions::Model) -> Self {
todo!()

Copilot AI Jul 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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(),
}

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +44
fn from(_: reactions::Model) -> Self {
todo!()

Copilot AI Jul 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conversion for reactions::Model is unimplemented (todo!()). Please implement mapping fields to ReactionItem or remove the stub if it's not needed.

Suggested change
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(),
}

Copilot uses AI. Check for mistakes.
@genedna
genedna added this pull request to the merge queue Jul 12, 2025
Merged via the queue into gitmono-dev:main with commit 87f665f Jul 12, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants