From 667ffb4239f303808d218ccbb7992054568de9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Sun, 22 Aug 2021 13:00:36 +0200 Subject: [PATCH 1/2] fix: correct create event warnings --- src/client_server/membership.rs | 5 ++++- src/database/rooms.rs | 5 ++++- src/server_server.rs | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/client_server/membership.rs b/src/client_server/membership.rs index 222d204..46f4b9f 100644 --- a/src/client_server/membership.rs +++ b/src/client_server/membership.rs @@ -822,7 +822,10 @@ pub async fn invite_helper<'a>( serde_json::from_value::>(create_event.content.clone()) .expect("Raw::from_value always works.") .deserialize() - .map_err(|_| Error::bad_database("Invalid PowerLevels event in db.")) + .map_err(|e| { + warn!("Invalid create event: {}", e); + Error::bad_database("Invalid create event in db.") + }) }) .transpose()?; diff --git a/src/database/rooms.rs b/src/database/rooms.rs index d3600f1..e83c1ab 100644 --- a/src/database/rooms.rs +++ b/src/database/rooms.rs @@ -1776,7 +1776,10 @@ impl Rooms { serde_json::from_value::>(create_event.content.clone()) .expect("Raw::from_value always works.") .deserialize() - .map_err(|_| Error::bad_database("Invalid PowerLevels event in db.")) + .map_err(|e| { + warn!("Invalid create event: {}", e); + Error::bad_database("Invalid create event in db.") + }) }) .transpose()?; diff --git a/src/server_server.rs b/src/server_server.rs index 5299e1f..ea2edce 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -1036,7 +1036,10 @@ fn handle_outlier_pdu<'a>( serde_json::from_value::>(create_event.content.clone()) .expect("Raw::from_value always works.") .deserialize() - .map_err(|_| "Invalid PowerLevels event in db.".to_owned())?; + .map_err(|e| { + warn!("Invalid create event: {}", e); + "Invalid create event in db.".to_owned() + })?; let room_version_id = &create_event_content.room_version; let room_version = RoomVersion::new(room_version_id).expect("room version is supported"); @@ -1323,7 +1326,10 @@ async fn upgrade_outlier_to_timeline_pdu( serde_json::from_value::>(create_event.content.clone()) .expect("Raw::from_value always works.") .deserialize() - .map_err(|_| "Invalid PowerLevels event in db.".to_owned())?; + .map_err(|e| { + warn!("Invalid create event: {}", e); + "Invalid create event in db.".to_owned() + })?; let room_version_id = &create_event_content.room_version; let room_version = RoomVersion::new(room_version_id).expect("room version is supported"); @@ -2210,7 +2216,10 @@ pub fn create_join_event_template_route( serde_json::from_value::>(create_event.content.clone()) .expect("Raw::from_value always works.") .deserialize() - .map_err(|_| Error::bad_database("Invalid PowerLevels event in db.")) + .map_err(|e| { + warn!("Invalid create event: {}", e); + Error::bad_database("Invalid create event in db.") + }) }) .transpose()?; From 6d83954c40f4768d4bd2a03fed34345ba3f8b00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Sun, 22 Aug 2021 13:05:56 +0200 Subject: [PATCH 2/2] fix: room upgrades --- src/client_server/room.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client_server/room.rs b/src/client_server/room.rs index 2541278..6981afc 100644 --- a/src/client_server/room.rs +++ b/src/client_server/room.rs @@ -423,6 +423,8 @@ pub async fn upgrade_room_route( // Create a replacement room let replacement_room = RoomId::new(db.globals.server_name()); + db.rooms + .get_or_create_shortroomid(&replacement_room, &db.globals)?; let mutex_state = Arc::clone( db.globals