diff options
Diffstat (limited to 'src/api/posts.rs')
-rw-r--r-- | src/api/posts.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/api/posts.rs b/src/api/posts.rs index 6830c1a..fda1fb1 100644 --- a/src/api/posts.rs +++ b/src/api/posts.rs @@ -19,11 +19,11 @@ impl Check for PostCreateRequest { async fn create(AuthorizedUser(user): AuthorizedUser, Json(body): Json<PostCreateRequest>) -> Response { let Ok(post) = Post::new(user.user_id, body.content) else { - return ResponseCode::InternalServerError.msg("Failed to create post") + return ResponseCode::InternalServerError.text("Failed to create post") }; let Ok(json) = serde_json::to_string(&post) else { - return ResponseCode::InternalServerError.msg("Failed to create post") + return ResponseCode::InternalServerError.text("Failed to create post") }; ResponseCode::Created.json(&json) @@ -43,11 +43,11 @@ impl Check for PostPageRequest { async fn page(AuthorizedUser(_user): AuthorizedUser, Json(body): Json<PostPageRequest>) -> Response { let Ok(posts) = Post::from_post_page(body.page) else { - return ResponseCode::InternalServerError.msg("Failed to fetch posts") + return ResponseCode::InternalServerError.text("Failed to fetch posts") }; let Ok(json) = serde_json::to_string(&posts) else { - return ResponseCode::InternalServerError.msg("Failed to fetch posts") + return ResponseCode::InternalServerError.text("Failed to fetch posts") }; ResponseCode::Success.json(&json) @@ -67,11 +67,11 @@ impl Check for UsersPostsRequest { async fn user(AuthorizedUser(_user): AuthorizedUser, Json(body): Json<UsersPostsRequest>) -> Response { let Ok(posts) = Post::from_user_id(body.user_id) else { - return ResponseCode::InternalServerError.msg("Failed to fetch posts") + return ResponseCode::InternalServerError.text("Failed to fetch posts") }; let Ok(json) = serde_json::to_string(&posts) else { - return ResponseCode::InternalServerError.msg("Failed to fetch posts") + return ResponseCode::InternalServerError.text("Failed to fetch posts") }; ResponseCode::Success.json(&json) @@ -93,14 +93,14 @@ impl Check for PostCommentRequest { async fn comment(AuthorizedUser(user): AuthorizedUser, Json(body): Json<PostCommentRequest>) -> Response { let Ok(mut post) = Post::from_post_id(body.post_id) else { - return ResponseCode::InternalServerError.msg("Failed to fetch posts") + return ResponseCode::InternalServerError.text("Failed to fetch posts") }; if let Err(err) = post.comment(user.user_id, body.content) { return err; } - ResponseCode::Success.msg("Successfully commented on post") + ResponseCode::Success.text("Successfully commented on post") } #[derive(Deserialize)] @@ -118,14 +118,14 @@ impl Check for PostLikeRequest { async fn like(AuthorizedUser(user): AuthorizedUser, Json(body): Json<PostLikeRequest>) -> Response { let Ok(mut post) = Post::from_post_id(body.post_id) else { - return ResponseCode::InternalServerError.msg("Failed to fetch posts") + return ResponseCode::InternalServerError.text("Failed to fetch posts") }; if let Err(err) = post.like(user.user_id, body.state) { return err; } - ResponseCode::Success.msg("Successfully changed like status on post") + ResponseCode::Success.text("Successfully changed like status on post") } pub fn router() -> Router { |