diff --git a/techtree-manager/src/main.rs b/techtree-manager/src/main.rs index 81cb520..5b7866a 100644 --- a/techtree-manager/src/main.rs +++ b/techtree-manager/src/main.rs @@ -49,20 +49,36 @@ async fn run() -> anyhow::Result<()> { let forgejo = Forgejo::new(auth, server_url).context("Could not create API access object")?; let new_comment_id = if meta.action == event_meta::IssueAction::Opened { - let res = issue::make_bot_comment(&forgejo, &meta, meta.issue.number).await; + let bot_comment = + issue::find_bot_comment(&forgejo, &meta.issue.repository, meta.issue.number) + .await + .with_context(|| { + format!( + "Failed searching for bot comment for issue #{}", + meta.issue.number + ) + })?; - let id = match res { - Ok(id) => Some(id), - Err(e) => { - log::warn!( - "Error while creating the informational comment on issue #{}:\n{e:?}", - meta.issue.number - ); - None + let id = match bot_comment { + Some(comment) => Some(comment.id), + None => { + let res = issue::make_bot_comment(&forgejo, &meta, meta.issue.number).await; + match res { + Ok(id) => Some(id), + Err(e) => { + log::warn!( + "Error while creating the informational comment on issue #{}:\n{e:?}", + meta.issue.number + ); + None + } + } } }; - log::info!("Waiting for a minute, as the issue is brand new. We will likely catch some more updates this way!"); + log::info!( + "Waiting for a minute, as the issue is brand new. We will likely catch some more updates this way!" + ); tokio::time::sleep(std::time::Duration::from_secs(60)).await; id