Merge branch 'small-logging-improvements' into 'next'
Slight logging improvements See merge request famedly/conduit!517
This commit is contained in:
commit
2b4a6c96ee
10 changed files with 57 additions and 28 deletions
|
@ -425,11 +425,10 @@ pub async fn get_room_event_route(
|
||||||
) -> Result<get_room_event::v3::Response> {
|
) -> Result<get_room_event::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
let event = services()
|
let event = services().rooms.timeline.get_pdu(&body.event_id)?.ok_or({
|
||||||
.rooms
|
warn!("Event not found, event ID: {:?}", &body.event_id);
|
||||||
.timeline
|
Error::BadRequest(ErrorKind::NotFound, "Event not found.")
|
||||||
.get_pdu(&body.event_id)?
|
})?;
|
||||||
.ok_or(Error::BadRequest(ErrorKind::NotFound, "Event not found."))?;
|
|
||||||
|
|
||||||
if !services().rooms.state_accessor.user_can_see_event(
|
if !services().rooms.state_accessor.user_can_see_event(
|
||||||
sender_user,
|
sender_user,
|
||||||
|
|
|
@ -9,7 +9,7 @@ use ruma::{
|
||||||
UserId,
|
UserId,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use tracing::info;
|
use tracing::{info, warn};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct Claims {
|
struct Claims {
|
||||||
|
@ -52,6 +52,7 @@ pub async fn login_route(body: Ruma<login::v3::Request>) -> Result<login::v3::Re
|
||||||
let username = if let UserIdentifier::UserIdOrLocalpart(user_id) = identifier {
|
let username = if let UserIdentifier::UserIdOrLocalpart(user_id) = identifier {
|
||||||
user_id.to_lowercase()
|
user_id.to_lowercase()
|
||||||
} else {
|
} else {
|
||||||
|
warn!("Bad login type: {:?}", &body.login_info);
|
||||||
return Err(Error::BadRequest(ErrorKind::Forbidden, "Bad login type."));
|
return Err(Error::BadRequest(ErrorKind::Forbidden, "Bad login type."));
|
||||||
};
|
};
|
||||||
let user_id =
|
let user_id =
|
||||||
|
@ -124,6 +125,7 @@ pub async fn login_route(body: Ruma<login::v3::Request>) -> Result<login::v3::Re
|
||||||
user_id
|
user_id
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
warn!("Unsupported or unknown login type: {:?}", &body.login_info);
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
ErrorKind::Unknown,
|
ErrorKind::Unknown,
|
||||||
"Unsupported login type.",
|
"Unsupported login type.",
|
||||||
|
|
|
@ -12,6 +12,7 @@ use ruma::{
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
EventId, RoomId, UserId,
|
EventId, RoomId, UserId,
|
||||||
};
|
};
|
||||||
|
use tracing::log::warn;
|
||||||
|
|
||||||
/// # `PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}`
|
/// # `PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}`
|
||||||
///
|
///
|
||||||
|
@ -129,10 +130,13 @@ pub async fn get_state_events_for_key_route(
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.room_state_get(&body.room_id, &body.event_type, &body.state_key)?
|
.room_state_get(&body.room_id, &body.event_type, &body.state_key)?
|
||||||
.ok_or(Error::BadRequest(
|
.ok_or({
|
||||||
ErrorKind::NotFound,
|
warn!(
|
||||||
"State event not found.",
|
"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 {
|
Ok(get_state_events_for_key::v3::Response {
|
||||||
content: serde_json::from_str(event.content.get())
|
content: serde_json::from_str(event.content.get())
|
||||||
|
@ -165,10 +169,13 @@ pub async fn get_state_events_for_empty_key_route(
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.room_state_get(&body.room_id, &body.event_type, "")?
|
.room_state_get(&body.room_id, &body.event_type, "")?
|
||||||
.ok_or(Error::BadRequest(
|
.ok_or({
|
||||||
ErrorKind::NotFound,
|
warn!(
|
||||||
"State event not found.",
|
"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 {
|
Ok(get_state_events_for_key::v3::Response {
|
||||||
content: serde_json::from_str(event.content.get())
|
content: serde_json::from_str(event.content.get())
|
||||||
|
|
|
@ -292,10 +292,8 @@ where
|
||||||
debug!("{:?}", http_request);
|
debug!("{:?}", http_request);
|
||||||
|
|
||||||
let body = T::try_from_http_request(http_request, &path_params).map_err(|e| {
|
let body = T::try_from_http_request(http_request, &path_params).map_err(|e| {
|
||||||
warn!(
|
warn!("try_from_http_request failed: {:?}", e);
|
||||||
"try_from_http_request failed: {:?}\nJSON body: {:?}",
|
debug!("JSON body: {:?}", json_body);
|
||||||
e, json_body
|
|
||||||
);
|
|
||||||
Error::BadRequest(ErrorKind::BadJson, "Failed to deserialize request.")
|
Error::BadRequest(ErrorKind::BadJson, "Failed to deserialize request.")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
|
@ -711,7 +711,8 @@ pub async fn send_transaction_message_route(
|
||||||
let (event_id, value, room_id) = match r {
|
let (event_id, value, room_id) = match r {
|
||||||
Ok(t) => t,
|
Ok(t) => t,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
warn!("Could not parse pdu: {e}");
|
warn!("Could not parse PDU: {e}");
|
||||||
|
warn!("Full PDU: {:?}", &pdu);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -952,7 +953,10 @@ pub async fn get_event_route(
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.get_pdu_json(&body.event_id)?
|
.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
|
let room_id_str = event
|
||||||
.get("room_id")
|
.get("room_id")
|
||||||
|
@ -1192,7 +1196,10 @@ pub async fn get_event_authorization_route(
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.get_pdu_json(&body.event_id)?
|
.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
|
let room_id_str = event
|
||||||
.get("room_id")
|
.get("room_id")
|
||||||
|
|
|
@ -433,6 +433,7 @@ fn routes() -> Router {
|
||||||
"/_matrix/client/v3/rooms/:room_id/initialSync",
|
"/_matrix/client/v3/rooms/:room_id/initialSync",
|
||||||
get(initial_sync),
|
get(initial_sync),
|
||||||
)
|
)
|
||||||
|
.route("/", get(it_works))
|
||||||
.fallback(not_found)
|
.fallback(not_found)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,6 +483,10 @@ async fn initial_sync(_uri: Uri) -> impl IntoResponse {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn it_works() -> &'static str {
|
||||||
|
"Hello from Conduit!"
|
||||||
|
}
|
||||||
|
|
||||||
trait RouterExt {
|
trait RouterExt {
|
||||||
fn ruma_route<H, T>(self, handler: H) -> Self
|
fn ruma_route<H, T>(self, handler: H) -> Self
|
||||||
where
|
where
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
mod data;
|
mod data;
|
||||||
pub use data::Data;
|
pub use data::Data;
|
||||||
use ruma::serde::Base64;
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId,
|
serde::Base64, OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedServerName,
|
||||||
|
OwnedServerSigningKeyId, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::api::server_server::FedDest;
|
use crate::api::server_server::FedDest;
|
||||||
|
@ -15,14 +15,16 @@ use ruma::{
|
||||||
},
|
},
|
||||||
DeviceId, RoomVersionId, ServerName, UserId,
|
DeviceId, RoomVersionId, ServerName, UserId,
|
||||||
};
|
};
|
||||||
use std::sync::atomic::{self, AtomicBool};
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, HashMap},
|
collections::{BTreeMap, HashMap},
|
||||||
fs,
|
fs,
|
||||||
future::Future,
|
future::Future,
|
||||||
net::{IpAddr, SocketAddr},
|
net::{IpAddr, SocketAddr},
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::{Arc, Mutex, RwLock},
|
sync::{
|
||||||
|
atomic::{self, AtomicBool},
|
||||||
|
Arc, Mutex, RwLock,
|
||||||
|
},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use tokio::sync::{broadcast, watch::Receiver, Mutex as TokioMutex, Semaphore};
|
use tokio::sync::{broadcast, watch::Receiver, Mutex as TokioMutex, Semaphore};
|
||||||
|
|
|
@ -1526,9 +1526,13 @@ impl Service {
|
||||||
if acl_event_content.is_allowed(server_name) {
|
if acl_event_content.is_allowed(server_name) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
info!(
|
||||||
|
"Server {} was denied by room ACL in {}",
|
||||||
|
server_name, room_id
|
||||||
|
);
|
||||||
Err(Error::BadRequest(
|
Err(Error::BadRequest(
|
||||||
ErrorKind::Forbidden,
|
ErrorKind::Forbidden,
|
||||||
"Server was denied by ACL",
|
"Server was denied by room ACL",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,7 +342,10 @@ impl Service {
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
let room_version = create_event_content
|
let room_version = create_event_content
|
||||||
.map(|create_event| create_event.room_version)
|
.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)
|
Ok(room_version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,9 @@ impl Service {
|
||||||
device_id: OwnedDeviceId,
|
device_id: OwnedDeviceId,
|
||||||
request: &mut sync_events::v4::Request,
|
request: &mut sync_events::v4::Request,
|
||||||
) -> BTreeMap<String, BTreeMap<OwnedRoomId, bool>> {
|
) -> BTreeMap<String, BTreeMap<OwnedRoomId, bool>> {
|
||||||
let Some(conn_id) = request.conn_id.clone() else { return BTreeMap::new(); };
|
let Some(conn_id) = request.conn_id.clone() else {
|
||||||
|
return BTreeMap::new();
|
||||||
|
};
|
||||||
|
|
||||||
let cache = &mut self.connections.lock().unwrap();
|
let cache = &mut self.connections.lock().unwrap();
|
||||||
let cached = Arc::clone(
|
let cached = Arc::clone(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue