Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions plugins/notification/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const EVENT_NOTIFICATION_WORKER_NAKE: &str = "event_notification_worker";

#[tracing::instrument(skip(ctx), name = EVENT_NOTIFICATION_WORKER_NAKE)]
pub async fn perform_event_notification(_job: Job, ctx: Data<WorkerState>) -> Result<(), Error> {
tracing::info!("Event notification worker executing - checking for events in next 5 minutes");
let latest_event = ctx
.db
.list_events(Some(ListEventFilter {
Expand All @@ -38,15 +39,32 @@ pub async fn perform_event_notification(_job: Job, ctx: Data<WorkerState>) -> Re
.map_err(|e| crate::Error::Db(e).as_worker_error())?;

if let Some(event) = latest_event.first() {
hypr_notification2::show(hypr_notification2::Notification {
title: "Meeting starting in 5 minutes".to_string(),
message: event.name.clone(),
url: Some(format!(
"hypr://hyprnote.com/notification?event_id={}",
event.id
)),
timeout: Some(std::time::Duration::from_secs(10)),
});
tracing::info!("Found upcoming event - showing notification");

// Wrap in AssertUnwindSafe and handle the panic properly
if let Err(e) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
hypr_notification2::show(hypr_notification2::Notification {
title: "Meeting starting in 5 minutes".to_string(),
message: event.name.clone(),
url: Some(format!(
"hypr://hyprnote.com/notification?event_id={}",
event.id
)),
timeout: Some(std::time::Duration::from_secs(10)),
});
})) {
// Convert panic payload to string for logging
let panic_msg = if let Some(s) = e.downcast_ref::<&str>() {
s.to_string()
} else if let Some(s) = e.downcast_ref::<String>() {
s.clone()
} else {
"Unknown panic".to_string()
};
tracing::error!("Notification panic: {}", panic_msg);
} else {
tracing::info!("Notification shown");
}
}

Ok(())
Expand Down
Loading