refactor(domain): move DB string conversions out of domain enums
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user