mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Add bio management feature with UI and backend support
This commit is contained in:
@@ -292,3 +292,18 @@ func ChangeUsername(uid uint, newUsername string) (model.UserView, error) {
|
||||
}
|
||||
return user.ToView(), nil
|
||||
}
|
||||
|
||||
func SetUserBio(uid uint, bio string) (model.UserView, error) {
|
||||
if len(bio) > 200 {
|
||||
return model.UserView{}, model.NewRequestError("Bio must be less than 200 characters")
|
||||
}
|
||||
user, err := dao.GetUserByID(uid)
|
||||
if err != nil {
|
||||
return model.UserView{}, err
|
||||
}
|
||||
user.Bio = bio
|
||||
if err := dao.UpdateUser(user); err != nil {
|
||||
return model.UserView{}, err
|
||||
}
|
||||
return user.ToView(), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user