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

@@ -9,26 +9,6 @@ pub enum NotificationType {
Mention,
Reply,
}
impl NotificationType {
pub fn from_db_str(s: &str) -> Self {
match s {
"like" => Self::Like,
"boost" => Self::Boost,
"follow" => Self::Follow,
"mention" => Self::Mention,
_ => Self::Reply,
}
}
pub fn as_str(&self) -> &str {
match self {
Self::Like => "like",
Self::Boost => "boost",
Self::Follow => "follow",
Self::Mention => "mention",
Self::Reply => "reply",
}
}
}
#[derive(Debug, Clone)]
pub struct Notification {

View File

@@ -25,22 +25,6 @@ pub enum FollowState {
Accepted,
Rejected,
}
impl FollowState {
pub fn from_db_str(s: &str) -> Self {
match s {
"pending" => Self::Pending,
"rejected" => Self::Rejected,
_ => Self::Accepted,
}
}
pub fn as_str(&self) -> &str {
match self {
Self::Pending => "pending",
Self::Accepted => "accepted",
Self::Rejected => "rejected",
}
}
}
#[derive(Debug, Clone)]
pub struct Follow {

View File

@@ -8,24 +8,6 @@ pub enum Visibility {
Unlisted,
Direct,
}
impl Visibility {
pub fn from_db_str(s: &str) -> Self {
match s {
"followers" => Self::Followers,
"unlisted" => Self::Unlisted,
"direct" => Self::Direct,
_ => Self::Public,
}
}
pub fn as_str(&self) -> &str {
match self {
Self::Public => "public",
Self::Followers => "followers",
Self::Unlisted => "unlisted",
Self::Direct => "direct",
}
}
}
#[derive(Debug, Clone)]
pub struct Thought {