rename forbidden_room_names to forbidden_alias_names

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-18 21:17:05 -04:00 committed by June
parent 5e880ac44a
commit 61f49ecf0e
6 changed files with 9 additions and 9 deletions

View file

@ -173,7 +173,7 @@ registration_token = "change this token for something specific to your server"
# This is checked upon room alias creation, custom room ID creation if used, and startup as warnings if any room aliases # This is checked upon room alias creation, custom room ID creation if used, and startup as warnings if any room aliases
# in your database have a forbidden room alias/ID. # in your database have a forbidden room alias/ID.
# No default. # No default.
# forbidden_room_names = [] # forbidden_alias_names = []
# Set this to true to allow your server's public room directory to be federated. # Set this to true to allow your server's public room directory to be federated.
# Set this to false to protect against /publicRooms spiders, but will forbid external users # Set this to false to protect against /publicRooms spiders, but will forbid external users

View file

@ -21,7 +21,7 @@ pub async fn create_alias_route(body: Ruma<create_alias::v3::Request>) -> Result
return Err(Error::BadRequest(ErrorKind::InvalidParam, "Alias is from another server.")); return Err(Error::BadRequest(ErrorKind::InvalidParam, "Alias is from another server."));
} }
if services().globals.forbidden_room_names().is_match(body.room_alias.alias()) { if services().globals.forbidden_alias_names().is_match(body.room_alias.alias()) {
return Err(Error::BadRequest(ErrorKind::Unknown, "Room alias is forbidden.")); return Err(Error::BadRequest(ErrorKind::Unknown, "Room alias is forbidden."));
} }

View file

@ -80,7 +80,7 @@ pub async fn create_room_route(body: Ruma<create_room::v3::Request>) -> Result<c
} }
// apply forbidden room alias checks to custom room IDs too // apply forbidden room alias checks to custom room IDs too
if services().globals.forbidden_room_names().is_match(&custom_room_id_s) { if services().globals.forbidden_alias_names().is_match(&custom_room_id_s) {
return Err(Error::BadRequest(ErrorKind::Unknown, "Custom room ID is forbidden.")); return Err(Error::BadRequest(ErrorKind::Unknown, "Custom room ID is forbidden."));
} }
@ -144,7 +144,7 @@ pub async fn create_room_route(body: Ruma<create_room::v3::Request>) -> Result<c
} }
// check if room alias is forbidden // check if room alias is forbidden
if services().globals.forbidden_room_names().is_match(localpart) { if services().globals.forbidden_alias_names().is_match(localpart) {
return Err(Error::BadRequest(ErrorKind::Unknown, "Room alias name is forbidden.")); return Err(Error::BadRequest(ErrorKind::Unknown, "Room alias name is forbidden."));
} }

View file

@ -172,7 +172,7 @@ pub struct Config {
#[serde(default = "RegexSet::empty")] #[serde(default = "RegexSet::empty")]
#[serde(with = "serde_regex")] #[serde(with = "serde_regex")]
pub forbidden_room_names: RegexSet, pub forbidden_alias_names: RegexSet,
#[serde(default = "RegexSet::empty")] #[serde(default = "RegexSet::empty")]
#[serde(with = "serde_regex")] #[serde(with = "serde_regex")]
@ -405,8 +405,8 @@ impl fmt::Display for Config {
("Forbidden usernames", { ("Forbidden usernames", {
&self.forbidden_usernames.patterns().iter().join(", ") &self.forbidden_usernames.patterns().iter().join(", ")
}), }),
("Forbidden room names", { ("Forbidden room aliases", {
&self.forbidden_room_names.patterns().iter().join(", ") &self.forbidden_alias_names.patterns().iter().join(", ")
}), }),
( (
"URL preview domain contains allowlist", "URL preview domain contains allowlist",

View file

@ -953,7 +953,7 @@ impl KeyValueDatabase {
} }
{ {
let patterns = &services().globals.config.forbidden_room_names; let patterns = &services().globals.config.forbidden_alias_names;
if !patterns.is_empty() { if !patterns.is_empty() {
for address in services().rooms.metadata.iter_ids() { for address in services().rooms.metadata.iter_ids() {
let room_id = address?; let room_id = address?;

View file

@ -345,7 +345,7 @@ impl Service<'_> {
pub fn url_preview_check_root_domain(&self) -> bool { self.config.url_preview_check_root_domain } pub fn url_preview_check_root_domain(&self) -> bool { self.config.url_preview_check_root_domain }
pub fn forbidden_room_names(&self) -> &RegexSet { &self.config.forbidden_room_names } pub fn forbidden_alias_names(&self) -> &RegexSet { &self.config.forbidden_alias_names }
pub fn forbidden_usernames(&self) -> &RegexSet { &self.config.forbidden_usernames } pub fn forbidden_usernames(&self) -> &RegexSet { &self.config.forbidden_usernames }