From db066c478f609204791a003be4b1a974b68a271e Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Thu, 10 Sep 2026 17:37:28 +0200 Subject: [PATCH] add get_note_comments backend function --- application/backend/src/backend.rs | 14 +++++++++++++- entity/src/comment.rs | 1 - 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/application/backend/src/backend.rs b/application/backend/src/backend.rs index a6e4141..a14eab8 100644 --- a/application/backend/src/backend.rs +++ b/application/backend/src/backend.rs @@ -43,7 +43,7 @@ use tokio::sync::{broadcast, mpsc}; use tokio::sync::broadcast::error::SendError; use migration::{Expr, Migrator, MigratorTrait}; -use entity::{attachment, attachmentcontent, collection, filecontent, note, notecontent, profile, repository}; +use entity::{attachment, attachmentcontent, collection, comment, filecontent, note, notecontent, profile, repository}; use entity::profile::Entity as Profile; use entity::collection::{create_notebook_hierarchy, CollectionType, Entity as Collection, Node}; use entity::note::{Column, Entity as Note, NoteType}; @@ -991,6 +991,18 @@ impl BackendHandle { let _ = self.tx.send(cmd); } + pub fn get_note_comments(&self, note_id: i32, callback: F) + where F: FnOnce(Result, DbErr>) + Send + 'static { + let backend = self.backend.clone(); + let cmd = Box::pin(async move { + let comments = comment::Entity::find() + .filter(comment::Column::NoteId.eq(note_id)) + .all(&backend.db).await; + callback(comments); + }); + let _ = self.tx.send(cmd); + } + pub fn open_extern(&self, note_id: i32, callback: F) where F: FnOnce(OpenExternResult) + Send + 'static { let backend = self.backend.clone(); diff --git a/entity/src/comment.rs b/entity/src/comment.rs index 3421aa2..80e181e 100644 --- a/entity/src/comment.rs +++ b/entity/src/comment.rs @@ -27,7 +27,6 @@ */ use sea_orm::entity::prelude::*; -use crate::note::NoteType; #[sea_orm::model] #[derive(Clone, Debug, PartialEq, DeriveEntityModel)] -- 2.52.0