diff --git a/src/client_server/account.rs b/src/client_server/account.rs index 81119ba3..f48543e2 100644 --- a/src/client_server/account.rs +++ b/src/client_server/account.rs @@ -2,6 +2,7 @@ use std::{collections::BTreeMap, convert::TryInto}; use super::{State, DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH}; use crate::{pdu::PduBuilder, utils, ConduitResult, Database, Error, Ruma}; +use log::info; use ruma::{ api::client::{ error::ErrorKind, @@ -510,6 +511,8 @@ pub async fn register_route( )?; } + info!("{} registered on this server", user_id); + db.flush().await?; Ok(register::Response { @@ -686,6 +689,8 @@ pub async fn deactivate_route( // Remove devices and mark account as deactivated db.users.deactivate_account(&sender_user)?; + info!("{} deactivated their account", sender_user); + db.flush().await?; Ok(deactivate::Response { diff --git a/src/client_server/directory.rs b/src/client_server/directory.rs index 202417e3..048b4100 100644 --- a/src/client_server/directory.rs +++ b/src/client_server/directory.rs @@ -1,5 +1,6 @@ use super::State; use crate::{server_server, ConduitResult, Database, Error, Result, Ruma}; +use log::info; use ruma::{ api::{ client::{ @@ -82,8 +83,13 @@ pub async fn set_room_visibility_route( db: State<'_, Database>, body: Ruma>, ) -> ConduitResult { + let sender_user = body.sender_user.as_ref().expect("user is authenticated"); + match body.visibility { - room::Visibility::Public => db.rooms.set_public(&body.room_id, true)?, + room::Visibility::Public => { + db.rooms.set_public(&body.room_id, true)?; + info!("{} made {} public", sender_user, body.room_id); + } room::Visibility::Private => db.rooms.set_public(&body.room_id, false)?, } diff --git a/src/client_server/room.rs b/src/client_server/room.rs index fdc9529a..a50f69c8 100644 --- a/src/client_server/room.rs +++ b/src/client_server/room.rs @@ -1,5 +1,6 @@ use super::State; use crate::{pdu::PduBuilder, ConduitResult, Database, Error, Ruma}; +use log::info; use ruma::{ api::client::{ error::ErrorKind, @@ -323,6 +324,8 @@ pub async fn create_room_route( db.rooms.set_public(&room_id, true)?; } + info!("{} created a room", sender_user); + db.flush().await?; Ok(create_room::Response::new(room_id).into()) diff --git a/src/client_server/session.rs b/src/client_server/session.rs index c8775ef5..da3d8d88 100644 --- a/src/client_server/session.rs +++ b/src/client_server/session.rs @@ -1,5 +1,6 @@ use super::{State, DEVICE_ID_LENGTH, TOKEN_LENGTH}; use crate::{utils, ConduitResult, Database, Error, Ruma}; +use log::info; use ruma::{ api::client::{ error::ErrorKind, @@ -93,6 +94,8 @@ pub async fn login_route( body.initial_device_display_name.clone(), )?; + info!("{} logged in", user_id); + db.flush().await?; Ok(login::Response { diff --git a/src/database.rs b/src/database.rs index 3f860c96..576a250e 100644 --- a/src/database.rs +++ b/src/database.rs @@ -39,9 +39,7 @@ impl Database { /// Tries to remove the old database but ignores all errors. pub fn try_remove(server_name: &str) -> Result<()> { let mut path = ProjectDirs::from("xyz", "koesters", "conduit") - .ok_or_else(|| Error::bad_config( - "The OS didn't return a valid home directory path.", - ))? + .ok_or_else(|| Error::bad_config("The OS didn't return a valid home directory path."))? .data_dir() .to_path_buf(); path.push(server_name); @@ -59,9 +57,9 @@ impl Database { .map(|x| Ok::<_, Error>(x.to_owned())) .unwrap_or_else(|_| { let path = ProjectDirs::from("xyz", "koesters", "conduit") - .ok_or_else(|| Error::bad_config( - "The OS didn't return a valid home directory path.", - ))? + .ok_or_else(|| { + Error::bad_config("The OS didn't return a valid home directory path.") + })? .data_dir() .join(server_name); diff --git a/src/error.rs b/src/error.rs index d54b3faa..4c24fd75 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,4 @@ -use std::{time::Duration, collections::HashMap, sync::RwLock, time::Instant}; +use std::{collections::HashMap, sync::RwLock, time::Duration, time::Instant}; use log::error; use ruma::{ diff --git a/src/server_server.rs b/src/server_server.rs index 0649bed1..d8d0fa52 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -61,9 +61,9 @@ where return Err(Error::bad_config("Federation is disabled.")); } - let resolver = AsyncResolver::tokio_from_system_conf() - .await - .map_err(|_| Error::bad_config("Failed to set up trust dns resolver with system config."))?; + let resolver = AsyncResolver::tokio_from_system_conf().await.map_err(|_| { + Error::bad_config("Failed to set up trust dns resolver with system config.") + })?; let mut host = None;