Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
httpd: Implement `EditCodeComment` in route
Alexis Sellier committed 2 years ago
commit d6e8f0c53e4176e6f9ada51b260b025825779c96
parent 369fc7637cb7e68a02f115bc6dfd69be15058a09
2 files changed +33 -2
modified 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)?;
modified radicle/src/cob/patch.rs
@@ -1078,6 +1078,20 @@ impl store::Transaction<Patch> {
        })
    }

+
    /// Edit comment on code.
+
    pub fn edit_code_comment<S: ToString>(
+
        &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<G: Signer, S: ToString>(
+
        &mut self,
+
        review: EntryId,
+
        comment: EntryId,
+
        body: S,
+
        signer: &G,
+
    ) -> Result<EntryId, Error> {
+
        self.transaction("Edit code comment", signer, |tx| {
+
            tx.edit_code_comment(review, comment, body)
+
        })
+
    }
+

    /// Review a patch revision.
    pub fn review<G: Signer>(
        &mut self,