refactor(domain): move DB string conversions out of domain enums

This commit is contained in:
2026-05-15 01:54:32 +02:00
parent a123c0b8cc
commit 344bcf34af
11 changed files with 124 additions and 74 deletions

View File

@@ -20,6 +20,16 @@ use axum::{
use domain::value_objects::ThoughtId;
use uuid::Uuid;
fn visibility_as_str(v: &domain::models::thought::Visibility) -> &'static str {
use domain::models::thought::Visibility;
match v {
Visibility::Public => "public",
Visibility::Followers => "followers",
Visibility::Unlisted => "unlisted",
Visibility::Direct => "direct",
}
}
fn thought_to_json(
t: &domain::models::thought::Thought,
author: &domain::models::user::User,
@@ -32,7 +42,7 @@ fn thought_to_json(
"content": t.content.as_str(),
"author": to_user_response(author),
"replyToId": t.in_reply_to_id.as_ref().map(|x| x.as_uuid()),
"visibility": t.visibility.as_str(),
"visibility": visibility_as_str(&t.visibility),
"contentWarning": t.content_warning,
"sensitive": t.sensitive,
"likeCount": like_count,