diff options
author | Felix <me@nutomic.com> | 2020-05-13 19:21:32 +0200 |
---|---|---|
committer | Felix <me@nutomic.com> | 2020-05-14 12:42:26 +0200 |
commit | bb1b4ee33e75917fb16f71fb302f867dd135ccf5 (patch) | |
tree | f80b17d0960bc06c286c60b7305ad8c9ddb60cb4 /server/src/apub/comment.rs | |
parent | 66142c546b4a7120b94bacc18cf478ae1905fd46 (diff) |
Comment search and apub endpoint
Diffstat (limited to 'server/src/apub/comment.rs')
-rw-r--r-- | server/src/apub/comment.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/server/src/apub/comment.rs b/server/src/apub/comment.rs index 17da45a6..4c2faa21 100644 --- a/server/src/apub/comment.rs +++ b/server/src/apub/comment.rs @@ -1,5 +1,24 @@ use super::*; +#[derive(Deserialize)] +pub struct CommentQuery { + comment_id: String, +} + +/// Return the post json over HTTP. +pub async fn get_apub_comment( + info: Path<CommentQuery>, + db: DbPoolParam, +) -> Result<HttpResponse<Body>, Error> { + let id = info.comment_id.parse::<i32>()?; + let comment = Comment::read(&&db.get()?, id)?; + if !comment.deleted { + Ok(create_apub_response(&comment.to_apub(&db.get().unwrap())?)) + } else { + Ok(create_apub_tombstone_response(&comment.to_tombstone()?)) + } +} + impl ToApub for Comment { type Response = Note; |