only log banned users if they are local

This was the intent of f03b6cde29, but it
was missing the check that the user is actually local, and so was
logging *all* banned users.
This commit is contained in:
Benjamin Lee 2024-08-30 22:59:38 -07:00
parent f03b6cde29
commit 4ad50e2708
No known key found for this signature in database
GPG key ID: FB9624E2885D55A4
2 changed files with 23 additions and 17 deletions

View file

@ -203,4 +203,5 @@ This will be the first release of Grapevine since it was forked from Conduit
13. Support building nix packages without IFD 13. Support building nix packages without IFD
([!73](https://gitlab.computer.surgery/matrix/grapevine-fork/-/merge_requests/73)) ([!73](https://gitlab.computer.surgery/matrix/grapevine-fork/-/merge_requests/73))
14. Report local users getting banned in the server logs and admin room. 14. Report local users getting banned in the server logs and admin room.
([!65](https://gitlab.computer.surgery/matrix/grapevine-fork/-/merge_requests/65)) ([!65](https://gitlab.computer.surgery/matrix/grapevine-fork/-/merge_requests/65),
[!84](https://gitlab.computer.surgery/matrix/grapevine-fork/-/merge_requests/84))

View file

@ -477,6 +477,9 @@ impl Service {
if membership == MembershipState::Ban { if membership == MembershipState::Ban {
let (room, user) = (&pdu.room_id, &target_user_id); let (room, user) = (&pdu.room_id, &target_user_id);
if user.server_name()
== services().globals.server_name()
{
info!( info!(
%user, %user,
%room, %room,
@ -484,7 +487,8 @@ impl Service {
"User has been banned from room" "User has been banned from room"
); );
let reason = match reason.filter(|s| !s.is_empty()) { let reason = match reason.filter(|s| !s.is_empty())
{
Some(s) => format!(": {s}"), Some(s) => format!(": {s}"),
None => String::new(), None => String::new(),
}; };
@ -496,6 +500,7 @@ impl Service {
)), )),
); );
} }
}
// Update our membership info, we do this here incase a user // Update our membership info, we do this here incase a user
// is invited and immediately leaves we // is invited and immediately leaves we