config option to allow/disallow federation profile requests

allow_profile_lookup_federation_requests

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-04-07 22:38:33 -04:00 committed by June
parent 85814e96e3
commit 973fed155e
4 changed files with 30 additions and 1 deletions

View file

@ -1425,16 +1425,27 @@ pub async fn get_room_information_route(
Ok(get_room_information::v1::Response {
room_id,
servers: vec![services().globals.server_name().to_owned()],
servers: vec![services().globals.server_name().to_owned()], // TODO: add more than just us
})
}
/// # `GET /_matrix/federation/v1/query/profile`
///
///
/// Gets information on a profile.
pub async fn get_profile_information_route(
body: Ruma<get_profile_information::v1::Request>,
) -> Result<get_profile_information::v1::Response> {
if !services()
.globals
.allow_profile_lookup_federation_requests()
{
return Err(Error::BadRequest(
ErrorKind::forbidden(),
"Profile lookup over federation is not allowed on this homeserver.",
));
}
if body.user_id.server_name() != services().globals.server_name() {
return Err(Error::BadRequest(
ErrorKind::InvalidParam,