]> uap-core.de Git - note.git/commitdiff
add content_type to the note entity main
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 3 Aug 2026 18:37:09 +0000 (20:37 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 3 Aug 2026 18:37:09 +0000 (20:37 +0200)
application/note/src/note.rs
entity/src/note.rs
migration/src/m20260502_184134_create_settings.rs

index a97cc0df9844692b9bd227ccc4832bf8a6c01b86..c0ed8b2b4a628dfd96d4f1afe9445cb6b142aefe 100644 (file)
@@ -29,7 +29,7 @@ use std::path::PathBuf;
 use std::rc::Rc;
 use std::sync::atomic::{AtomicU64, Ordering};
 use std::time::SystemTime;
-use sea_orm::{NotSet, Set};
+use sea_orm::{Iden, NotSet, Set};
 use sea_orm::sea_query::prelude::Utc;
 use backend::backend::{BackendHandle, BroadcastMessage, NoteContentRet, NoteId, NoteTitleUpdate, SaveNoteResult};
 use backend::lockmanager::NoteLock;
@@ -558,12 +558,18 @@ impl NoteViewModel for Note {
             NoteId::TmpId(_) => (NotSet, Set(Utc::now().into()))
         };
 
+        let content_type = match self.kind {
+            NoteType::MDTextNote => "text/markdown",
+            _ => "text/plain"
+        };
+
         let note = entity::note::ActiveModel {
             note_id: note_id.clone(),
             collection_id: Set(self.collection_id),
             nodename: if let Some(nodename) = &self.nodename { Set(nodename.clone())} else { NotSet },
             kind: Set(self.kind.clone()),
             title: Set(title),
+            content_type: Set(content_type.to_string()),
             lastmodified: Set(Utc::now().into()),
             created: created,
             fixed_title: Set(self.fixed_title),
index c130f63b9589df77b9e8beb7caf1240fa5cf1a74..55d860318f97ad519999e0c136932ca975358008 100644 (file)
@@ -39,6 +39,7 @@ pub struct Model {
 
     pub kind: NoteType,
     pub title: String,
+    pub content_type: String,
 
     pub lastmodified: DateTimeWithTimeZone,
     pub created: DateTimeWithTimeZone,
@@ -70,6 +71,7 @@ impl Model {
             nodename: "".to_string(),
             kind: Default::default(),
             title: Default::default(),
+            content_type: Default::default(),
             lastmodified: Default::default(),
             created: Default::default(),
             fixed_title: false,
index f2d678541d172bfb1acc797328da0c14c36fabee..7517da9442eaec01ba659f80ec2904f81ceb0db5 100644 (file)
@@ -74,6 +74,7 @@ impl MigrationTrait for Migration {
                     .col(string("nodename"))
                     .col(integer("kind"))
                     .col(string("title"))
+                    .col(string("content_type"))
                     .col(timestamp_with_time_zone("lastmodified"))
                     .col(timestamp_with_time_zone("created"))
                     .col(boolean("fixed_title"))