Update dependencies and enhance WebSocket server logging: Add 'chrono' and 'android_system_properties' to Cargo.lock, improve error handling and logging in websocket_server.rs, and streamline character creation notifications in worker modules for better clarity and maintainability.
This commit is contained in:
@@ -20,9 +20,9 @@ use crate::worker::sql::{
|
||||
QUERY_DELETE_DIRECTOR,
|
||||
QUERY_DELETE_RELATIONSHIP,
|
||||
QUERY_DELETE_CHILD_RELATION,
|
||||
QUERY_INSERT_NOTIFICATION,
|
||||
QUERY_MARK_CHARACTER_DECEASED,
|
||||
};
|
||||
use crate::worker::{insert_notification, publish_update_status};
|
||||
|
||||
pub struct CharacterCreationWorker {
|
||||
pub(crate) base: BaseWorker,
|
||||
@@ -417,48 +417,12 @@ impl CharacterCreationWorker {
|
||||
// 2) Relationships löschen und betroffene User benachrichtigen
|
||||
conn.prepare("delete_relationship", QUERY_DELETE_RELATIONSHIP)?;
|
||||
let rel_result = conn.execute("delete_relationship", &[&character_id])?;
|
||||
|
||||
// Logging: Anzahl gelöschter Relationships
|
||||
let deleted_count = rel_result.len();
|
||||
if deleted_count > 0 {
|
||||
eprintln!(
|
||||
"[CharacterCreationWorker] {} Relationship(s) gelöscht für character_id={}",
|
||||
deleted_count, character_id
|
||||
);
|
||||
}
|
||||
|
||||
for row in rel_result {
|
||||
let related_user_id = row
|
||||
if let Some(related_user_id) = row
|
||||
.get("related_user_id")
|
||||
.and_then(|v| v.parse::<i32>().ok());
|
||||
let related_character_id = row
|
||||
.get("related_character_id")
|
||||
.and_then(|v| v.parse::<i32>().ok());
|
||||
let relationship_type_tr = row
|
||||
.get("relationship_type_tr")
|
||||
.map(|s| s.to_string());
|
||||
|
||||
// Logging: Relationship wurde gelöscht
|
||||
eprintln!(
|
||||
"[CharacterCreationWorker] Relationship gelöscht: character_id={}, related_character_id={:?}, related_user_id={:?}, relationship_type={:?}",
|
||||
character_id,
|
||||
related_character_id,
|
||||
related_user_id,
|
||||
relationship_type_tr
|
||||
);
|
||||
|
||||
if let Some(uid) = related_user_id {
|
||||
// Spezielle Notification für Verlobungen
|
||||
if relationship_type_tr.as_deref() == Some("engaged") {
|
||||
use crate::worker::insert_notification;
|
||||
let notification_json = serde_json::json!({
|
||||
"tr": "relationship.engaged_character_death",
|
||||
"character_id": related_character_id
|
||||
});
|
||||
insert_notification(pool, uid, ¬ification_json.to_string(), related_character_id)?;
|
||||
} else {
|
||||
Self::notify_user(pool, broker, uid, "relationship_death")?;
|
||||
}
|
||||
.and_then(|v| v.parse::<i32>().ok())
|
||||
{
|
||||
Self::notify_user(pool, broker, related_user_id, "relationship_death")?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,11 +456,17 @@ impl CharacterCreationWorker {
|
||||
user_id: i32,
|
||||
event_type: &str,
|
||||
) -> Result<(), DbError> {
|
||||
// DB-Notification (zentralisiert). Historisch wird hier als `tr` der event_type-String gespeichert.
|
||||
insert_notification(pool, user_id, event_type, None)?;
|
||||
let mut conn = pool
|
||||
.get()
|
||||
.map_err(|e| DbError::new(format!("DB-Verbindung fehlgeschlagen: {e}")))?;
|
||||
|
||||
// Frontend-Update (zentralisiert)
|
||||
publish_update_status(broker, user_id);
|
||||
conn.prepare("insert_notification", QUERY_INSERT_NOTIFICATION)?;
|
||||
conn.execute("insert_notification", &[&user_id])?;
|
||||
|
||||
// falukantUpdateStatus
|
||||
let update_message =
|
||||
format!(r#"{{"event":"falukantUpdateStatus","user_id":{}}}"#, user_id);
|
||||
broker.publish(update_message);
|
||||
|
||||
// ursprüngliche Benachrichtigung
|
||||
let message =
|
||||
|
||||
Reference in New Issue
Block a user