From d6e8f0c53e4176e6f9ada51b260b025825779c96 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Thu, 29 Jun 2023 15:39:52 +0200 Subject: [PATCH] httpd: Implement `EditCodeComment` in route --- radicle-httpd/src/api/v1/projects.rs | 8 ++++++-- radicle/src/cob/patch.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/radicle-httpd/src/api/v1/projects.rs b/radicle-httpd/src/api/v1/projects.rs index b80dc7df..2a4612b9 100644 --- a/radicle-httpd/src/api/v1/projects.rs +++ b/radicle-httpd/src/api/v1/projects.rs @@ -647,8 +647,12 @@ async fn patch_update_handler( patch::Action::EditReview { review, summary } => { patch.edit_review(review, summary, &signer)?; } - patch::Action::EditCodeComment { .. } => { - todo!() + patch::Action::EditCodeComment { + review, + comment, + body, + } => { + patch.edit_code_comment(review, comment, body, &signer)?; } patch::Action::Tag { add, remove } => { patch.tag(add, remove, &signer)?; diff --git a/radicle/src/cob/patch.rs b/radicle/src/cob/patch.rs index 3e8fe05e..1a658ac9 100644 --- a/radicle/src/cob/patch.rs +++ b/radicle/src/cob/patch.rs @@ -1078,6 +1078,20 @@ impl store::Transaction { }) } + /// Edit comment on code. + pub fn edit_code_comment( + &mut self, + review: EntryId, + comment: EntryId, + body: S, + ) -> Result<(), store::Error> { + self.push(Action::EditCodeComment { + review, + comment, + body: body.to_string(), + }) + } + /// Review a patch revision. pub fn review( &mut self, @@ -1255,6 +1269,19 @@ impl<'a, 'g> PatchMut<'a, 'g> { }) } + /// Edit comment on code. + pub fn edit_code_comment( + &mut self, + review: EntryId, + comment: EntryId, + body: S, + signer: &G, + ) -> Result { + self.transaction("Edit code comment", signer, |tx| { + tx.edit_code_comment(review, comment, body) + }) + } + /// Review a patch revision. pub fn review( &mut self,