From: Olaf Wintermann Date: Wed, 19 Aug 2026 16:59:55 +0000 (+0200) Subject: add backend function for getting a list of note attachments X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=HEAD;p=note.git add backend function for getting a list of note attachments --- diff --git a/application/backend/src/backend.rs b/application/backend/src/backend.rs index d5e8d61..75dbbf3 100644 --- a/application/backend/src/backend.rs +++ b/application/backend/src/backend.rs @@ -42,7 +42,7 @@ use tokio::sync::{broadcast, mpsc}; use tokio::sync::broadcast::error::SendError; use migration::{Expr, Migrator, MigratorTrait}; -use entity::{collection, filecontent, note, notecontent, profile, repository}; +use entity::{attachment, collection, 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}; @@ -874,6 +874,18 @@ impl BackendHandle { }); let _ = self.tx.send(cmd); } + + pub fn get_note_attachments(&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 attachments = attachment::Entity::find() + .filter(attachment::Column::NoteId.eq(note_id)) + .all(&backend.db).await; + callback(attachments); + }); + let _ = self.tx.send(cmd); + } pub fn open_extern(&self, note_id: i32, callback: F) where F: FnOnce(OpenExternResult) + Send + 'static { diff --git a/entity/src/lib.rs b/entity/src/lib.rs index 08b265d..9d8afc0 100644 --- a/entity/src/lib.rs +++ b/entity/src/lib.rs @@ -5,5 +5,5 @@ pub mod note; pub mod notecontent; pub mod repository; pub mod filecontent; -mod attachment; -mod attachmentcontent; \ No newline at end of file +pub mod attachment; +pub mod attachmentcontent; \ No newline at end of file