Skip to content

Commit 3e2b749

Browse files
coderabbit suggestion fix
1 parent 2cfd329 commit 3e2b749

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/alerts/mod.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -512,16 +512,13 @@ impl AlertState {
512512
// from here, the user can only go to Resolved
513513
if new_state == AlertState::Resolved {
514514
// update state on disk and in memory
515-
let guard = ALERTS.write().await;
516-
if let Some(alerts) = guard.as_ref() {
517-
alerts
518-
.update_state(alert_id, new_state, Some("".into()))
519-
.await?;
520-
}
521-
522-
// ALERTS
523-
// .update_state(alert_id, new_state, Some("".into()))
524-
// .await?;
515+
let guard = ALERTS.read().await;
516+
let alerts = guard.as_ref().ok_or_else(|| {
517+
AlertError::CustomError("Alert manager not initialized".into())
518+
})?;
519+
alerts
520+
.update_state(alert_id, new_state, Some("".into()))
521+
.await?;
525522
} else {
526523
let msg = format!("Not allowed to manually go from Silenced to {new_state}");
527524
return Err(AlertError::InvalidStateChange(msg));

0 commit comments

Comments
 (0)