Add config to control m.federate in room create events. (fixes #151)
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -413,6 +413,12 @@ async fn create_create_event(
|
|||||||
))))
|
))))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
if !services.config.federate_created_rooms {
|
||||||
|
if !services.config.allow_federation || !content.contains_key("m.federate") {
|
||||||
|
content.insert("m.federate".into(), json!(false).try_into()?);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
content.insert(
|
content.insert(
|
||||||
"room_version".into(),
|
"room_version".into(),
|
||||||
json!(room_version.as_str())
|
json!(room_version.as_str())
|
||||||
@@ -428,6 +434,10 @@ async fn create_create_event(
|
|||||||
let mut content =
|
let mut content =
|
||||||
serde_json::from_str::<CanonicalJsonObject>(to_raw_value(&content)?.get())?;
|
serde_json::from_str::<CanonicalJsonObject>(to_raw_value(&content)?.get())?;
|
||||||
|
|
||||||
|
if !services.config.federate_created_rooms {
|
||||||
|
content.insert("m.federate".into(), json!(false).try_into()?);
|
||||||
|
}
|
||||||
|
|
||||||
content.insert("room_version".into(), json!(room_version.as_str()).try_into()?);
|
content.insert("room_version".into(), json!(room_version.as_str()).try_into()?);
|
||||||
content
|
content
|
||||||
},
|
},
|
||||||
@@ -535,6 +545,12 @@ async fn create_create_event_legacy(
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !services.config.federate_created_rooms {
|
||||||
|
if !services.config.allow_federation || !content.contains_key("m.federate") {
|
||||||
|
content.insert("m.federate".into(), json!(false).try_into()?);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
content.insert(
|
content.insert(
|
||||||
"room_version".into(),
|
"room_version".into(),
|
||||||
json!(room_version.as_str())
|
json!(room_version.as_str())
|
||||||
@@ -556,6 +572,10 @@ async fn create_create_event_legacy(
|
|||||||
let mut content =
|
let mut content =
|
||||||
serde_json::from_str::<CanonicalJsonObject>(to_raw_value(&content)?.get())?;
|
serde_json::from_str::<CanonicalJsonObject>(to_raw_value(&content)?.get())?;
|
||||||
|
|
||||||
|
if !services.config.federate_created_rooms {
|
||||||
|
content.insert("m.federate".into(), json!(false).try_into()?);
|
||||||
|
}
|
||||||
|
|
||||||
content.insert("room_version".into(), json!(room_version.as_str()).try_into()?);
|
content.insert("room_version".into(), json!(room_version.as_str()).try_into()?);
|
||||||
content
|
content
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -560,10 +560,21 @@ pub struct Config {
|
|||||||
pub allow_encryption: bool,
|
pub allow_encryption: bool,
|
||||||
|
|
||||||
/// Controls whether federation is allowed or not. It is not recommended to
|
/// Controls whether federation is allowed or not. It is not recommended to
|
||||||
/// disable this after the fact due to potential federation breakage.
|
/// disable this after installation due to potential federation breakage but
|
||||||
|
/// this is technically not a permanent setting.
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub allow_federation: bool,
|
pub allow_federation: bool,
|
||||||
|
|
||||||
|
/// Sets the default `m.federate` property for newly created rooms when the
|
||||||
|
/// client does not request one. If `allow_federation` is set to false at
|
||||||
|
/// the same this value is set to false it then always overrides the client
|
||||||
|
/// requested `m.federate` value to false.
|
||||||
|
///
|
||||||
|
/// Rooms are fixed to the setting at the time of their creation and can
|
||||||
|
/// never be changed; changing this value only affects new rooms.
|
||||||
|
#[serde(default = "true_fn")]
|
||||||
|
pub federate_created_rooms: bool,
|
||||||
|
|
||||||
/// Allows federation requests to be made to itself
|
/// Allows federation requests to be made to itself
|
||||||
///
|
///
|
||||||
/// This isn't intended and is very likely a bug if federation requests are
|
/// This isn't intended and is very likely a bug if federation requests are
|
||||||
|
|||||||
@@ -435,10 +435,21 @@
|
|||||||
#allow_encryption = true
|
#allow_encryption = true
|
||||||
|
|
||||||
# Controls whether federation is allowed or not. It is not recommended to
|
# Controls whether federation is allowed or not. It is not recommended to
|
||||||
# disable this after the fact due to potential federation breakage.
|
# disable this after installation due to potential federation breakage but
|
||||||
|
# this is technically not a permanent setting.
|
||||||
#
|
#
|
||||||
#allow_federation = true
|
#allow_federation = true
|
||||||
|
|
||||||
|
# Sets the default `m.federate` property for newly created rooms when the
|
||||||
|
# client does not request one. If `allow_federation` is set to false at
|
||||||
|
# the same this value is set to false it then always overrides the client
|
||||||
|
# requested `m.federate` value to false.
|
||||||
|
#
|
||||||
|
# Rooms are fixed to the setting at the time of their creation and can
|
||||||
|
# never be changed; changing this value only affects new rooms.
|
||||||
|
#
|
||||||
|
#federate_created_rooms = true
|
||||||
|
|
||||||
# Allows federation requests to be made to itself
|
# Allows federation requests to be made to itself
|
||||||
#
|
#
|
||||||
# This isn't intended and is very likely a bug if federation requests are
|
# This isn't intended and is very likely a bug if federation requests are
|
||||||
|
|||||||
Reference in New Issue
Block a user