feat: refactor author username assignment in ThoughtSchema

This commit is contained in:
2025-09-07 22:37:12 +02:00
parent 08213133be
commit 2083f3bb16

View File

@@ -23,9 +23,15 @@ pub struct ThoughtSchema {
impl ThoughtSchema {
pub fn from_models(thought: &thought::Model, author: &user::Model) -> Self {
let author_username = if let Some(display_name) = author.display_name.clone() {
display_name
} else {
author.username.clone()
};
Self {
id: thought.id,
author_username: author.username.clone(),
author_username,
content: thought.content.clone(),
visibility: thought.visibility.clone(),
reply_to_id: thought.reply_to_id,