diff --git a/crates/radicle/src/cob/issue.rs b/crates/radicle/src/cob/issue.rs index 0fd572781..c31f349a1 100644 --- a/crates/radicle/src/cob/issue.rs +++ b/crates/radicle/src/cob/issue.rs @@ -373,7 +373,7 @@ impl Issue { Action::Comment { .. } => Authorization::Allow, // All roles can edit or redact their own comments. Action::CommentEdit { id, .. } | Action::CommentRedact { id, .. } => { - if let Some(comment) = self.thread.comments.get(id) { + if let Some(comment) = self.thread.get_comment(id) { if let Some(comment) = comment { Authorization::from(actor == comment.author()) } else { diff --git a/crates/radicle/src/cob/thread.rs b/crates/radicle/src/cob/thread.rs index e15dd1289..c7a692707 100644 --- a/crates/radicle/src/cob/thread.rs +++ b/crates/radicle/src/cob/thread.rs @@ -289,7 +289,7 @@ impl From for nonempty::NonEmpty { #[serde(rename_all = "camelCase")] pub struct Thread { /// The comments under the thread. - pub(crate) comments: BTreeMap>, + comments: BTreeMap>, /// Comment timeline. pub(crate) timeline: Vec, } @@ -357,6 +357,10 @@ impl Thread { pub fn timeline(&self) -> impl DoubleEndedIterator + '_ { self.timeline.iter() } + + pub fn get_comment(&self, id: &CommentId) -> Option<&Option> { + self.comments.get(id) + } } impl Thread {