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.
This commit is contained in:
@@ -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::<i32>().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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user