From 233059883a9ecdc5a2b8a0b0692db9bb645b9f6a Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Wed, 19 Aug 2026 18:59:55 +0200 Subject: [PATCH] add backend function for getting a list of note attachments --- application/backend/src/backend.rs | 14 +++++++++++++- entity/src/lib.rs | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) 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 -- 2.52.0