]> uap-core.de Git - note.git/commitdiff
add get_note_comments backend function
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 10 Sep 2026 15:37:28 +0000 (17:37 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 10 Sep 2026 15:37:28 +0000 (17:37 +0200)
application/backend/src/backend.rs
entity/src/comment.rs

index a6e4141dca35c13be67d87194eb8913853321993..a14eab82df63efc617f545cc7559592cf7591135 100644 (file)
@@ -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<F>(&self, note_id: i32, callback: F)
+    where F: FnOnce(Result<Vec<comment::Model>, 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<F>(&self, note_id: i32, callback: F)
     where F: FnOnce(OpenExternResult) + Send + 'static {
         let backend = self.backend.clone();
index 3421aa23cf136615eec0aa09c785de264807d781..80e181e46c7ef2ea7f426af2f85eff107fe67814 100644 (file)
@@ -27,7 +27,6 @@
  */
 
 use sea_orm::entity::prelude::*;
-use crate::note::NoteType;
 
 #[sea_orm::model]
 #[derive(Clone, Debug, PartialEq, DeriveEntityModel)]