summaryrefslogtreecommitdiff
path: root/src/types/post.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/types/post.rs')
-rw-r--r--src/types/post.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/types/post.rs b/src/types/post.rs
index 94f0a9e..7805a4e 100644
--- a/src/types/post.rs
+++ b/src/types/post.rs
@@ -18,7 +18,7 @@ impl Post {
pub fn from_post_id(post_id: u64) -> Result<Self> {
let Ok(Some(post)) = database::posts::get_post(post_id) else {
- return Err(ResponseCode::BadRequest.msg("Post does not exist"))
+ return Err(ResponseCode::BadRequest.text("Post does not exist"))
};
Ok(post)
@@ -35,21 +35,21 @@ impl Post {
pub fn from_post_page(page: u64) -> Result<Vec<Self>> {
let Ok(posts) = database::posts::get_post_page(page) else {
- return Err(ResponseCode::BadRequest.msg("Failed to fetch posts"))
+ return Err(ResponseCode::BadRequest.text("Failed to fetch posts"))
};
Ok(posts)
}
pub fn from_user_id(user_id: u64) -> Result<Vec<Self>> {
let Ok(posts) = database::posts::get_users_posts(user_id) else {
- return Err(ResponseCode::BadRequest.msg("Failed to fetch posts"))
+ return Err(ResponseCode::BadRequest.text("Failed to fetch posts"))
};
Ok(posts)
}
pub fn new(user_id: u64, content: String) -> Result<Self> {
let Ok(post) = database::posts::add_post(user_id, &content) else {
- return Err(ResponseCode::InternalServerError.msg("Failed to create post"))
+ return Err(ResponseCode::InternalServerError.text("Failed to create post"))
};
Ok(post)
@@ -59,7 +59,7 @@ impl Post {
self.comments.push((user_id, content));
if database::posts::update_post(self.post_id, &self.likes, &self.comments).is_err() {
- return Err(ResponseCode::InternalServerError.msg("Failed to comment on post"))
+ return Err(ResponseCode::InternalServerError.text("Failed to comment on post"))
}
Ok(())
@@ -74,7 +74,7 @@ impl Post {
}
if database::posts::update_post(self.post_id, &self.likes, &self.comments).is_err() {
- return Err(ResponseCode::InternalServerError.msg("Failed to comment on post"))
+ return Err(ResponseCode::InternalServerError.text("Failed to comment on post"))
}
Ok(())