Notify admin room for user registrations, deactivations and password changes

This commit is contained in:
Andrej Kacian 2022-02-22 00:02:01 +01:00
parent 738f5e8f68
commit b5b8181851

View File

@ -17,6 +17,7 @@ use ruma::{
}, },
events::{ events::{
room::member::{MembershipState, RoomMemberEventContent}, room::member::{MembershipState, RoomMemberEventContent},
room::message::RoomMessageEventContent,
EventType, EventType,
}, },
push, UserId, push, UserId,
@ -230,7 +231,12 @@ pub async fn register_route(
body.initial_device_display_name.clone(), body.initial_device_display_name.clone(),
)?; )?;
info!("{} registered on this server", user_id); info!("New user {} registered on this server.", user_id);
db.admin
.send_message(RoomMessageEventContent::notice_plain(format!(
"New user {} registered on this server.",
user_id
)));
// If this is the first real user, grant them admin privileges // If this is the first real user, grant them admin privileges
// Note: the server user, @conduit:servername, is generated first // Note: the server user, @conduit:servername, is generated first
@ -319,6 +325,13 @@ pub async fn change_password_route(
db.flush()?; db.flush()?;
info!("User {} changed their password.", sender_user);
db.admin
.send_message(RoomMessageEventContent::notice_plain(format!(
"User {} changed their password.",
sender_user
)));
Ok(change_password::v3::Response {}) Ok(change_password::v3::Response {})
} }
@ -436,7 +449,12 @@ pub async fn deactivate_route(
// Remove devices and mark account as deactivated // Remove devices and mark account as deactivated
db.users.deactivate_account(sender_user)?; db.users.deactivate_account(sender_user)?;
info!("{} deactivated their account", sender_user); info!("User {} deactivated their account.", sender_user);
db.admin
.send_message(RoomMessageEventContent::notice_plain(format!(
"User {} deactivated their account.",
sender_user
)));
db.flush()?; db.flush()?;