summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgirlbossceo <june@girlboss.ceo>2023-07-28 23:40:10 +0000
committergirlbossceo <june@girlboss.ceo>2023-07-29 14:29:26 +0000
commitcc5dcceacc38483209502d120b56407db9ad3055 (patch)
tree4c6fe63889cfc4de892ba961119c4e85c26b3670
parent863103450c876711e1d2dfead103f2bfa358a2aa (diff)
downloadconduit-cc5dcceacc38483209502d120b56407db9ad3055.zip
Log the room ID, event ID, PDU, and event type where possible
Signed-off-by: girlbossceo <june@girlboss.ceo>
-rw-r--r--src/api/client_server/room.rs4
-rw-r--r--src/api/client_server/state.rs16
-rw-r--r--src/api/server_server.rs11
-rw-r--r--src/service/rooms/state/mod.rs4
4 files changed, 23 insertions, 12 deletions
diff --git a/src/api/client_server/room.rs b/src/api/client_server/room.rs
index 8c39b78..7bdccae 100644
--- a/src/api/client_server/room.rs
+++ b/src/api/client_server/room.rs
@@ -429,7 +429,9 @@ pub async fn get_room_event_route(
.rooms
.timeline
.get_pdu(&body.event_id)?
- .ok_or(Error::BadRequest(ErrorKind::NotFound, "Event not found."))?;
+ .ok_or({
+ warn!("Event not found, event ID: {:?}", &body.event_id);
+ Error::BadRequest(ErrorKind::NotFound, "Event not found.")})?;
if !services().rooms.state_accessor.user_can_see_event(
sender_user,
diff --git a/src/api/client_server/state.rs b/src/api/client_server/state.rs
index 8e4ceaf..5ea7e99 100644
--- a/src/api/client_server/state.rs
+++ b/src/api/client_server/state.rs
@@ -12,6 +12,7 @@ use ruma::{
serde::Raw,
EventId, RoomId, UserId,
};
+use tracing::log::warn;
/// # `PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}`
///
@@ -129,10 +130,11 @@ pub async fn get_state_events_for_key_route(
.rooms
.state_accessor
.room_state_get(&body.room_id, &body.event_type, &body.state_key)?
- .ok_or(Error::BadRequest(
- ErrorKind::NotFound,
+ .ok_or({
+ warn!("State event {:?} not found in room {:?}", &body.event_type, &body.room_id);
+ Error::BadRequest(ErrorKind::NotFound,
"State event not found.",
- ))?;
+ )})?;
Ok(get_state_events_for_key::v3::Response {
content: serde_json::from_str(event.content.get())
@@ -165,10 +167,10 @@ pub async fn get_state_events_for_empty_key_route(
.rooms
.state_accessor
.room_state_get(&body.room_id, &body.event_type, "")?
- .ok_or(Error::BadRequest(
- ErrorKind::NotFound,
- "State event not found.",
- ))?;
+ .ok_or({
+ warn!("State event {:?} not found in room {:?}", &body.event_type, &body.room_id);
+ Error::BadRequest(ErrorKind::NotFound,
+ "State event not found.",)})?;
Ok(get_state_events_for_key::v3::Response {
content: serde_json::from_str(event.content.get())
diff --git a/src/api/server_server.rs b/src/api/server_server.rs
index 9a1b680..95716e7 100644
--- a/src/api/server_server.rs
+++ b/src/api/server_server.rs
@@ -711,7 +711,8 @@ pub async fn send_transaction_message_route(
let (event_id, value, room_id) = match r {
Ok(t) => t,
Err(e) => {
- warn!("Could not parse pdu: {e}");
+ warn!("Could not parse PDU: {e}");
+ warn!("Full PDU: {:?}", &pdu);
continue;
}
};
@@ -952,7 +953,9 @@ pub async fn get_event_route(
.rooms
.timeline
.get_pdu_json(&body.event_id)?
- .ok_or(Error::BadRequest(ErrorKind::NotFound, "Event not found."))?;
+ .ok_or({
+ warn!("Event not found, event ID: {:?}", &body.event_id);
+ Error::BadRequest(ErrorKind::NotFound, "Event not found.")})?;
let room_id_str = event
.get("room_id")
@@ -1192,7 +1195,9 @@ pub async fn get_event_authorization_route(
.rooms
.timeline
.get_pdu_json(&body.event_id)?
- .ok_or(Error::BadRequest(ErrorKind::NotFound, "Event not found."))?;
+ .ok_or({
+ warn!("Event not found, event ID: {:?}", &body.event_id);
+ Error::BadRequest(ErrorKind::NotFound, "Event not found.")})?;
let room_id_str = event
.get("room_id")
diff --git a/src/service/rooms/state/mod.rs b/src/service/rooms/state/mod.rs
index d782386..48e3d79 100644
--- a/src/service/rooms/state/mod.rs
+++ b/src/service/rooms/state/mod.rs
@@ -342,7 +342,9 @@ impl Service {
.transpose()?;
let room_version = create_event_content
.map(|create_event| create_event.room_version)
- .ok_or(Error::BadDatabase("Invalid room version"))?;
+ .ok_or({
+ warn!("Invalid room version for room {room_id}");
+ Error::BadDatabase("Invalid room version")})?;
Ok(room_version)
}