feat: update JSON keys in user profile and top friends API for consistency
This commit is contained in:
@@ -132,7 +132,10 @@ pub async fn update_user_profile(
|
|||||||
|
|
||||||
pub async fn get_top_friends(db: &DbConn, user_id: Uuid) -> Result<Vec<user::Model>, DbErr> {
|
pub async fn get_top_friends(db: &DbConn, user_id: Uuid) -> Result<Vec<user::Model>, DbErr> {
|
||||||
user::Entity::find()
|
user::Entity::find()
|
||||||
.join(JoinType::InnerJoin, top_friends::Relation::User.def().rev())
|
.join(
|
||||||
|
JoinType::InnerJoin,
|
||||||
|
top_friends::Relation::Friend.def().rev(),
|
||||||
|
)
|
||||||
.filter(top_friends::Column::UserId.eq(user_id))
|
.filter(top_friends::Column::UserId.eq(user_id))
|
||||||
.order_by_asc(top_friends::Column::Position)
|
.order_by_asc(top_friends::Column::Position)
|
||||||
.all(db)
|
.all(db)
|
||||||
|
@@ -69,7 +69,7 @@ async fn test_thought_replies() {
|
|||||||
// 2. User 2 replies to the original thought
|
// 2. User 2 replies to the original thought
|
||||||
let reply_body = json!({
|
let reply_body = json!({
|
||||||
"content": "This is a reply.",
|
"content": "This is a reply.",
|
||||||
"reply_to_id": original_thought_id
|
"replyToId": original_thought_id
|
||||||
})
|
})
|
||||||
.to_string();
|
.to_string();
|
||||||
let response =
|
let response =
|
||||||
|
@@ -90,9 +90,9 @@ async fn test_me_endpoints() {
|
|||||||
|
|
||||||
// 4. PUT /users/me to update the profile
|
// 4. PUT /users/me to update the profile
|
||||||
let update_body = json!({
|
let update_body = json!({
|
||||||
"display_name": "Me User",
|
"displayName": "Me User",
|
||||||
"bio": "This is my updated bio.",
|
"bio": "This is my updated bio.",
|
||||||
"avatar_url": "https://example.com/avatar.png"
|
"avatarUrl": "https://example.com/avatar.png"
|
||||||
})
|
})
|
||||||
.to_string();
|
.to_string();
|
||||||
let response = make_jwt_request(
|
let response = make_jwt_request(
|
||||||
@@ -137,7 +137,7 @@ async fn test_update_me_top_friends() {
|
|||||||
|
|
||||||
// 3. Update profile to set top friends
|
// 3. Update profile to set top friends
|
||||||
let update_body = json!({
|
let update_body = json!({
|
||||||
"top_friends": ["friend1", "friend2"]
|
"topFriends": ["friend1", "friend2"]
|
||||||
})
|
})
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ async fn test_update_me_top_friends() {
|
|||||||
|
|
||||||
// 5. Update again with a different list to test replacement
|
// 5. Update again with a different list to test replacement
|
||||||
let update_body_2 = json!({
|
let update_body_2 = json!({
|
||||||
"top_friends": ["friend2"]
|
"topFriends": ["friend2"]
|
||||||
})
|
})
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ async fn test_update_me_css_and_images() {
|
|||||||
|
|
||||||
// 2. Attempt to update with an invalid avatar URL
|
// 2. Attempt to update with an invalid avatar URL
|
||||||
let invalid_body = json!({
|
let invalid_body = json!({
|
||||||
"avatar_url": "not-a-valid-url"
|
"avatarUrl": "not-a-valid-url"
|
||||||
})
|
})
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
@@ -219,9 +219,9 @@ async fn test_update_me_css_and_images() {
|
|||||||
|
|
||||||
// 3. Update profile with valid URLs and custom CSS
|
// 3. Update profile with valid URLs and custom CSS
|
||||||
let valid_body = json!({
|
let valid_body = json!({
|
||||||
"avatar_url": "https://example.com/new-avatar.png",
|
"avatarUrl": "https://example.com/new-avatar.png",
|
||||||
"header_url": "https://example.com/new-header.jpg",
|
"headerUrl": "https://example.com/new-header.jpg",
|
||||||
"custom_css": "body { color: blue; }"
|
"customCss": "body { color: blue; }"
|
||||||
})
|
})
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user