From 02967fc69e0f50b183619b7d9ed4890306b0bf71 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Mon, 3 Aug 2026 20:37:09 +0200 Subject: [PATCH] add content_type to the note entity --- application/note/src/note.rs | 8 +++++++- entity/src/note.rs | 2 ++ migration/src/m20260502_184134_create_settings.rs | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/application/note/src/note.rs b/application/note/src/note.rs index a97cc0d..c0ed8b2 100644 --- a/application/note/src/note.rs +++ b/application/note/src/note.rs @@ -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), diff --git a/entity/src/note.rs b/entity/src/note.rs index c130f63..55d8603 100644 --- a/entity/src/note.rs +++ b/entity/src/note.rs @@ -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, diff --git a/migration/src/m20260502_184134_create_settings.rs b/migration/src/m20260502_184134_create_settings.rs index f2d6785..7517da9 100644 --- a/migration/src/m20260502_184134_create_settings.rs +++ b/migration/src/m20260502_184134_create_settings.rs @@ -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")) -- 2.52.0