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.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/types/post.rs b/src/types/post.rs
index 90eada2..7397009 100644
--- a/src/types/post.rs
+++ b/src/types/post.rs
@@ -51,6 +51,14 @@ impl Post {
}
#[instrument()]
+ pub fn reterieve_all() -> Result<Vec<Self>> {
+ let Ok(posts) = database::posts::get_all_posts() else {
+ return Err(ResponseCode::InternalServerError.text("Failed to fetch posts"))
+ };
+ Ok(posts)
+ }
+
+ #[instrument()]
pub fn new(user_id: u64, content: String) -> Result<Self> {
let Ok(post) = database::posts::add_post(user_id, &content) else {
tracing::error!("Failed to create post");