From b4b3b1adcc0e8dd5b8a2b8d3b431d255f787b519 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 8 Dec 2025 13:29:18 +0100 Subject: [PATCH] Enhance user notification structure in EventsWorker: Updated the notification process to include detailed event information in the database entries. Notifications now contain event ID, type, and effects, improving clarity and data integrity for user alerts. --- src/worker/events.rs | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/worker/events.rs b/src/worker/events.rs index 97902a1..af5319a 100644 --- a/src/worker/events.rs +++ b/src/worker/events.rs @@ -543,8 +543,14 @@ impl EventsWorker { } } - // Schreibe Benachrichtigung in die Datenbank - Self::notify_user(pool, broker, user_id, &format!("random_event.{}", event.id))?; + // Schreibe Benachrichtigung in die Datenbank mit Event-Details + let notification_json = serde_json::json!({ + "tr": format!("random_event.{}", event.id), + "event_id": event.id, + "event_type": "personal", + "effects": effect_results + }); + Self::notify_user(pool, broker, user_id, ¬ification_json.to_string())?; // Sende Benachrichtigung über WebSocket let notification = json!({ @@ -644,7 +650,17 @@ impl EventsWorker { } } - // Sende Benachrichtigung + // Schreibe Benachrichtigung in die Datenbank mit Event-Details + let notification_json = serde_json::json!({ + "tr": format!("random_event.{}", event.id), + "event_id": event.id, + "event_type": "personal", + "character_id": character_id, + "effects": effect_results + }); + Self::notify_user(pool, broker, user_id, ¬ification_json.to_string())?; + + // Sende Benachrichtigung über WebSocket let notification = json!({ "event": "random_event", "event_id": event.id, @@ -895,8 +911,15 @@ impl EventsWorker { .and_then(|v| v.parse::().ok()); if let Some(uid) = user_id { - // Schreibe Benachrichtigung in die Datenbank - if let Err(err) = Self::notify_user(pool, broker, uid, &format!("random_event.{}", event.id)) { + // Schreibe Benachrichtigung in die Datenbank mit Event-Details + let notification_json = serde_json::json!({ + "tr": format!("random_event.{}", event.id), + "event_id": event.id, + "event_type": "regional", + "region_id": region_id, + "effects": effect_results + }); + if let Err(err) = Self::notify_user(pool, broker, uid, ¬ification_json.to_string()) { eprintln!("[EventsWorker] Fehler beim Schreiben der Benachrichtigung für User {}: {}", uid, err); }