feat: implement user follow/unfollow functionality and thought retrieval by user
- Added follow and unfollow endpoints for users. - Implemented logic to retrieve thoughts by a specific user. - Updated user error handling to include cases for already following and not following. - Created persistence layer for follow relationships. - Enhanced user and thought schemas to support new features. - Added tests for follow/unfollow endpoints and thought retrieval. - Updated frontend to display thoughts and allow posting new thoughts.
This commit is contained in:
@@ -1,12 +1,22 @@
|
||||
#[derive(Debug)]
|
||||
pub enum UserError {
|
||||
NotFound,
|
||||
NotFollowing,
|
||||
Forbidden,
|
||||
UsernameTaken,
|
||||
AlreadyFollowing,
|
||||
Internal(String),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for UserError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
UserError::NotFound => write!(f, "User not found"),
|
||||
UserError::NotFollowing => write!(f, "You are not following this user"),
|
||||
UserError::Forbidden => write!(f, "You do not have permission to perform this action"),
|
||||
UserError::UsernameTaken => write!(f, "Username is already taken"),
|
||||
UserError::AlreadyFollowing => write!(f, "You are already following this user"),
|
||||
UserError::Internal(msg) => write!(f, "Internal server error: {}", msg),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user