Füge Fehlerberichterstattung für Benachrichtigungen über Charaktertode hinzu und verhindere wiederholte Meldungen innerhalb von fünf Minuten.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 2m53s

This commit is contained in:
Torsten Schulz (local)
2026-09-03 07:41:34 +02:00
parent d7318564e0
commit 508418b058
4 changed files with 189 additions and 37 deletions

View File

@@ -1923,12 +1923,14 @@ impl EventsWorker {
let tr = death_ctx.as_ref().map(|c| {
death_log::wrap_death_notification(c, "director_death", user_id)
});
Self::notify_user(
if let Err(e) = Self::notify_user(
pool,
broker,
user_id,
tr.as_deref().unwrap_or("director_death"),
)?;
) {
eprintln!("[EventsWorker] director_death notification: {e}");
}
}
}
@@ -1943,12 +1945,14 @@ impl EventsWorker {
let tr = death_ctx.as_ref().map(|c| {
death_log::wrap_death_notification(c, "relationship_death", related_user_id)
});
Self::notify_user(
if let Err(e) = Self::notify_user(
pool,
broker,
related_user_id,
tr.as_deref().unwrap_or("relationship_death"),
)?;
) {
eprintln!("[EventsWorker] relationship_death notification: {e}");
}
}
}
@@ -1981,12 +1985,14 @@ impl EventsWorker {
let tr = death_ctx.as_ref().map(|c| {
death_log::wrap_death_notification(c, "child_death", father_user_id)
});
Self::notify_user(
if let Err(e) = Self::notify_user(
pool,
broker,
father_user_id,
tr.as_deref().unwrap_or("child_death"),
)?;
) {
eprintln!("[EventsWorker] child_death notification (father): {e}");
}
}
if let Some(mother_user_id) = row
.get("mother_user_id")
@@ -1995,12 +2001,14 @@ impl EventsWorker {
let tr = death_ctx.as_ref().map(|c| {
death_log::wrap_death_notification(c, "child_death", mother_user_id)
});
Self::notify_user(
if let Err(e) = Self::notify_user(
pool,
broker,
mother_user_id,
tr.as_deref().unwrap_or("child_death"),
)?;
) {
eprintln!("[EventsWorker] child_death notification (mother): {e}");
}
}
}

View File

@@ -2150,7 +2150,14 @@ pub const QUERY_GET_MARRIAGE_BIRTH_DELIVERIES: &str = r#"
r.id AS relationship_id,
CASE WHEN c1.gender = 'male' THEN c1.id ELSE c2.id END AS father_cid,
CASE WHEN c1.gender = 'female' THEN c1.id ELSE c2.id END AS mother_cid,
CASE WHEN c1.gender = 'male' THEN c1.title_of_nobility ELSE c2.title_of_nobility END AS title_of_nobility,
-- Kinder eines Spielers erben stets dessen Titel, unabhängig vom Geschlecht.
-- Bei reinen NPC-Paaren bleibt der Titel des Vaters maßgeblich.
CASE
WHEN c1.user_id IS NOT NULL THEN c1.title_of_nobility
WHEN c2.user_id IS NOT NULL THEN c2.title_of_nobility
WHEN c1.gender = 'male' THEN c1.title_of_nobility
ELSE c2.title_of_nobility
END AS title_of_nobility,
CASE WHEN c1.gender = 'male' THEN c1.last_name ELSE c2.last_name END AS last_name,
CASE WHEN c1.gender = 'male' THEN c1.region_id ELSE c2.region_id END AS region_id,
CASE WHEN c1.gender = 'male' THEN fu1.id ELSE fu2.id END AS father_uid,
@@ -2204,7 +2211,12 @@ pub const QUERY_TRY_MARRIAGE_CONCEPTION_UPDATE: &str = r#"
r.id AS relationship_id,
CASE WHEN c1.gender = 'male' THEN c1.id ELSE c2.id END AS father_cid,
CASE WHEN c1.gender = 'female' THEN c1.id ELSE c2.id END AS mother_cid,
CASE WHEN c1.gender = 'male' THEN c1.title_of_nobility ELSE c2.title_of_nobility END AS title_of_nobility,
CASE
WHEN c1.user_id IS NOT NULL THEN c1.title_of_nobility
WHEN c2.user_id IS NOT NULL THEN c2.title_of_nobility
WHEN c1.gender = 'male' THEN c1.title_of_nobility
ELSE c2.title_of_nobility
END AS title_of_nobility,
CASE WHEN c1.gender = 'male' THEN c1.last_name ELSE c2.last_name END AS last_name,
CASE WHEN c1.gender = 'male' THEN c1.region_id ELSE c2.region_id END AS region_id,
CASE WHEN c1.gender = 'male' THEN fu1.id ELSE fu2.id END AS father_uid,
@@ -2269,7 +2281,12 @@ pub const QUERY_GET_LEGACY_MARRIAGE_INSTANT_PREGNANCY_CANDIDATES: &str = r#"
SELECT
CASE WHEN c1.gender = 'male' THEN c1.id ELSE c2.id END AS father_cid,
CASE WHEN c1.gender = 'female' THEN c1.id ELSE c2.id END AS mother_cid,
CASE WHEN c1.gender = 'male' THEN c1.title_of_nobility ELSE c2.title_of_nobility END AS title_of_nobility,
CASE
WHEN c1.user_id IS NOT NULL THEN c1.title_of_nobility
WHEN c2.user_id IS NOT NULL THEN c2.title_of_nobility
WHEN c1.gender = 'male' THEN c1.title_of_nobility
ELSE c2.title_of_nobility
END AS title_of_nobility,
CASE WHEN c1.gender = 'male' THEN c1.last_name ELSE c2.last_name END AS last_name,
CASE WHEN c1.gender = 'male' THEN c1.region_id ELSE c2.region_id END AS region_id,
CASE WHEN c1.gender = 'male' THEN fu1.id ELSE fu2.id END AS father_uid,
@@ -2343,7 +2360,12 @@ pub const QUERY_GET_PLANNED_CHARACTER_BIRTH_DELIVERIES: &str = r#"
SELECT
c_m.id AS mother_cid,
c_f.id AS father_cid,
CASE WHEN c_f.gender = 'male' THEN c_f.title_of_nobility ELSE c_m.title_of_nobility END AS title_of_nobility,
CASE
WHEN c_f.user_id IS NOT NULL THEN c_f.title_of_nobility
WHEN c_m.user_id IS NOT NULL THEN c_m.title_of_nobility
WHEN c_f.gender = 'male' THEN c_f.title_of_nobility
ELSE c_m.title_of_nobility
END AS title_of_nobility,
CASE WHEN c_f.gender = 'male' THEN c_f.last_name ELSE c_m.last_name END AS last_name,
CASE WHEN c_f.gender = 'male' THEN c_f.region_id ELSE c_m.region_id END AS region_id,
fu_f.id AS father_uid,
@@ -3899,7 +3921,12 @@ pub const QUERY_GET_LOVER_PREGNANCY_CANDIDATES: &str = r#"
SELECT
CASE WHEN c1.gender = 'male' THEN c1.id ELSE c2.id END AS father_cid,
CASE WHEN c1.gender = 'female' THEN c1.id ELSE c2.id END AS mother_cid,
CASE WHEN c1.gender = 'male' THEN c1.title_of_nobility ELSE c2.title_of_nobility END AS title_of_nobility,
CASE
WHEN c1.user_id IS NOT NULL THEN c1.title_of_nobility
WHEN c2.user_id IS NOT NULL THEN c2.title_of_nobility
WHEN c1.gender = 'male' THEN c1.title_of_nobility
ELSE c2.title_of_nobility
END AS title_of_nobility,
CASE WHEN c1.gender = 'male' THEN c1.last_name ELSE c2.last_name END AS last_name,
CASE WHEN c1.gender = 'male' THEN c1.region_id ELSE c2.region_id END AS region_id,
CASE WHEN c1.gender = 'male' THEN fu1.id ELSE fu2.id END AS father_uid,

View File

@@ -864,11 +864,13 @@ impl UserCharacterWorker {
let tr = death_ctx.as_ref().map(|c| {
death_log::wrap_death_notification(c, "director_death", user_id)
});
self.notify_user_death(
if let Err(e) = self.notify_user_death(
&mut conn,
user_id,
tr.as_deref().unwrap_or("director_death"),
)?;
) {
eprintln!("[UserCharacterWorker] director_death notification: {e}");
}
}
}
@@ -881,11 +883,13 @@ impl UserCharacterWorker {
let tr = death_ctx.as_ref().map(|c| {
death_log::wrap_death_notification(c, "relationship_death", related_user_id)
});
self.notify_user_death(
if let Err(e) = self.notify_user_death(
&mut conn,
related_user_id,
tr.as_deref().unwrap_or("relationship_death"),
)?;
) {
eprintln!("[UserCharacterWorker] relationship_death notification: {e}");
}
}
}
@@ -899,11 +903,13 @@ impl UserCharacterWorker {
let tr = death_ctx.as_ref().map(|c| {
death_log::wrap_death_notification(c, "child_death", father_user_id)
});
self.notify_user_death(
if let Err(e) = self.notify_user_death(
&mut conn,
father_user_id,
tr.as_deref().unwrap_or("child_death"),
)?;
) {
eprintln!("[UserCharacterWorker] child_death notification (father): {e}");
}
}
if let Some(mother_user_id) = row
.get("mother_user_id")
@@ -912,11 +918,13 @@ impl UserCharacterWorker {
let tr = death_ctx.as_ref().map(|c| {
death_log::wrap_death_notification(c, "child_death", mother_user_id)
});
self.notify_user_death(
if let Err(e) = self.notify_user_death(
&mut conn,
mother_user_id,
tr.as_deref().unwrap_or("child_death"),
)?;
) {
eprintln!("[UserCharacterWorker] child_death notification (mother): {e}");
}
}
}
conn.execute("delete_knowledge", &[&character_id])?;