feat: enhance user registration and follow functionality, add popular tags endpoint, and update tests
This commit is contained in:
@@ -6,7 +6,7 @@ pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub follower_id: Uuid,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub followed_id: Uuid,
|
||||
pub following_id: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
@@ -21,12 +21,12 @@ pub enum Relation {
|
||||
Follower,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::user::Entity",
|
||||
from = "Column::FollowedId",
|
||||
from = "Column::FollowingId",
|
||||
to = "super::user::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Followed,
|
||||
Following,
|
||||
}
|
||||
|
||||
impl Related<super::user::Entity> for Entity {
|
||||
|
@@ -6,6 +6,8 @@ use validator::Validate;
|
||||
pub struct RegisterParams {
|
||||
#[validate(length(min = 3))]
|
||||
pub username: String,
|
||||
#[validate(email)]
|
||||
pub email: String,
|
||||
#[validate(length(min = 6))]
|
||||
pub password: String,
|
||||
}
|
||||
|
@@ -14,12 +14,26 @@ pub struct UserSchema {
|
||||
pub avatar_url: Option<String>,
|
||||
pub header_url: Option<String>,
|
||||
pub custom_css: Option<String>,
|
||||
// In a real implementation, you'd fetch and return this data.
|
||||
// For now, we'll omit it from the schema to keep it simple.
|
||||
// pub top_friends: Vec<String>,
|
||||
pub top_friends: Vec<String>,
|
||||
pub joined_at: DateTimeWithTimeZoneWrapper,
|
||||
}
|
||||
|
||||
impl From<(user::Model, Vec<user::Model>)> for UserSchema {
|
||||
fn from((user, top_friends): (user::Model, Vec<user::Model>)) -> Self {
|
||||
Self {
|
||||
id: user.id,
|
||||
username: user.username,
|
||||
display_name: user.display_name,
|
||||
bio: user.bio,
|
||||
avatar_url: user.avatar_url,
|
||||
header_url: user.header_url,
|
||||
custom_css: user.custom_css,
|
||||
top_friends: top_friends.into_iter().map(|u| u.username).collect(),
|
||||
joined_at: user.created_at.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<user::Model> for UserSchema {
|
||||
fn from(user: user::Model) -> Self {
|
||||
Self {
|
||||
@@ -30,6 +44,7 @@ impl From<user::Model> for UserSchema {
|
||||
avatar_url: user.avatar_url,
|
||||
header_url: user.header_url,
|
||||
custom_css: user.custom_css,
|
||||
top_friends: vec![], // Defaults to an empty list
|
||||
joined_at: user.created_at.into(),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user