From ea981634d04bee0be69d150d3267d63a1e7780a7 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Tue, 29 Oct 2024 12:08:03 +0100 Subject: [PATCH] Add `create_issue_comment_handler` --- crates/test-http-api/src/api.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/test-http-api/src/api.rs b/crates/test-http-api/src/api.rs index bbbf6127e..20a9cd8bb 100644 --- a/crates/test-http-api/src/api.rs +++ b/crates/test-http-api/src/api.rs @@ -61,6 +61,7 @@ pub fn router(ctx: Context) -> Router { .route("/get_diff", post(diff_handler)) .route("/list_issues", post(issues_handler)) .route("/create_issue", post(create_issue_handler)) + .route("/create_issue_comment", post(create_issue_comment_handler)) .route("/edit_issue", post(edit_issue_handler)) .route("/issue_by_id", post(issue_handler)) .route("/list_patches", post(patches_handler)) @@ -172,6 +173,22 @@ async fn create_issue_handler( Ok::<_, Error>(Json(issues)) } +#[derive(Serialize, Deserialize)] +struct CreateIssueCommentBody { + pub rid: identity::RepoId, + pub new: types::cobs::thread::NewIssueComment, + pub opts: types::cobs::CobOptions, +} + +async fn create_issue_comment_handler( + State(ctx): State, + Json(CreateIssueCommentBody { rid, opts, new }): Json, +) -> impl IntoResponse { + let comment = ctx.create_issue_comment(rid, new, opts)?; + + Ok::<_, Error>(Json(comment)) +} + #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] struct EditIssuesBody {