httpd: Implement `EditCodeComment` in route

This commit is contained in:
Alexis Sellier 2023-06-29 15:39:52 +02:00
parent 369fc7637c
commit d6e8f0c53e
No known key found for this signature in database
2 changed files with 33 additions and 2 deletions

View File

@ -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)?;

View File

@ -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,