summaryrefslogtreecommitdiff
path: root/src/api/posts.rs
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2023-01-28 02:51:34 -0500
committerTyler Murphy <tylermurphy534@gmail.com>2023-01-28 02:51:34 -0500
commitc01b8b8c90fa762f25bf52437611643e3ca16e5a (patch)
treec93293c5c074a03808cdd4b85cdf6001f2f17dd6 /src/api/posts.rs
parentrusty boio finished (diff)
downloadxssbook-c01b8b8c90fa762f25bf52437611643e3ca16e5a.tar.gz
xssbook-c01b8b8c90fa762f25bf52437611643e3ca16e5a.tar.bz2
xssbook-c01b8b8c90fa762f25bf52437611643e3ca16e5a.zip
fix rerendering logout button, console page
Diffstat (limited to 'src/api/posts.rs')
-rw-r--r--src/api/posts.rs20
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 {