From 6abbd39926f37545ed9981b6130018cf8325d1c2 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Mon, 14 Aug 2023 16:40:33 +0200 Subject: [PATCH] httpd: Allow removing of reactions from issues Signed-off-by: Sebastian Martinez --- radicle-cli/src/commands/issue.rs | 2 +- radicle-httpd/src/api/v1/projects.rs | 8 ++++++-- radicle/src/cob/issue.rs | 14 ++++++++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/radicle-cli/src/commands/issue.rs b/radicle-cli/src/commands/issue.rs index fe815fbc..622d01e4 100644 --- a/radicle-cli/src/commands/issue.rs +++ b/radicle-cli/src/commands/issue.rs @@ -323,7 +323,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { let (comment_id, _) = term::io::comment_select(&issue).unwrap(); *comment_id }); - issue.react(comment_id, reaction, &signer)?; + issue.react(comment_id, reaction, true, &signer)?; } } Operation::Open { diff --git a/radicle-httpd/src/api/v1/projects.rs b/radicle-httpd/src/api/v1/projects.rs index 6addd4d1..9b930e72 100644 --- a/radicle-httpd/src/api/v1/projects.rs +++ b/radicle-httpd/src/api/v1/projects.rs @@ -553,8 +553,12 @@ async fn issue_update_handler( return Err(Error::BadRequest("`replyTo` missing".to_owned())); } } - issue::Action::CommentReact { id, reaction, .. } => { - issue.react(id, reaction, &signer)?; + issue::Action::CommentReact { + id, + reaction, + active, + } => { + issue.react(id, reaction, active, &signer)?; } issue::Action::CommentEdit { .. } => { todo!(); diff --git a/radicle/src/cob/issue.rs b/radicle/src/cob/issue.rs index eff8da19..f2784590 100644 --- a/radicle/src/cob/issue.rs +++ b/radicle/src/cob/issue.rs @@ -291,11 +291,16 @@ impl store::Transaction { } /// React to an issue comment. - pub fn react(&mut self, id: CommentId, reaction: Reaction) -> Result<(), store::Error> { + pub fn react( + &mut self, + id: CommentId, + reaction: Reaction, + active: bool, + ) -> Result<(), store::Error> { self.push(Action::CommentReact { id, reaction, - active: true, + active, }) } @@ -406,9 +411,10 @@ where &mut self, to: CommentId, reaction: Reaction, + active: bool, signer: &G, ) -> Result { - self.transaction("React", signer, |tx| tx.react(to, reaction)) + self.transaction("React", signer, |tx| tx.react(to, reaction, active)) } pub fn transaction( @@ -875,7 +881,7 @@ mod test { let (comment, _) = issue.root(); let comment = *comment; let reaction = Reaction::new('🥳').unwrap(); - issue.react(comment, reaction, &node.signer).unwrap(); + issue.react(comment, reaction, true, &node.signer).unwrap(); let id = issue.id; let issue = issues.get(&id).unwrap().unwrap();