mirror of
https://github.com/RightNow-AI/openfang.git
synced 2026-07-30 23:05:08 +00:00
Merge pull request #711 from Reaster0/fix/matrix-configurable-auto-accept-invites
fix(matrix): make auto_accept_invites configurable, default to false
This commit is contained in:
@@ -1219,6 +1219,7 @@ pub async fn start_channel_bridge_with_config(
|
||||
mx_config.user_id.clone(),
|
||||
token,
|
||||
mx_config.allowed_rooms.clone(),
|
||||
mx_config.auto_accept_invites,
|
||||
));
|
||||
adapters.push((adapter, mx_config.default_agent.clone()));
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ impl MatrixAdapter {
|
||||
user_id: String,
|
||||
access_token: String,
|
||||
allowed_rooms: Vec<String>,
|
||||
auto_accept_invites: bool,
|
||||
) -> Self {
|
||||
let (shutdown_tx, shutdown_rx) = watch::channel(false);
|
||||
Self {
|
||||
@@ -57,7 +58,7 @@ impl MatrixAdapter {
|
||||
shutdown_tx: Arc::new(shutdown_tx),
|
||||
shutdown_rx,
|
||||
since_token: Arc::new(RwLock::new(None)),
|
||||
auto_accept_invites: true,
|
||||
auto_accept_invites,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,6 +462,7 @@ mod tests {
|
||||
"@bot:matrix.org".to_string(),
|
||||
"access_token".to_string(),
|
||||
vec![],
|
||||
false,
|
||||
);
|
||||
assert_eq!(adapter.name(), "matrix");
|
||||
}
|
||||
@@ -472,6 +474,7 @@ mod tests {
|
||||
"@bot:matrix.org".to_string(),
|
||||
"token".to_string(),
|
||||
vec!["!room1:matrix.org".to_string()],
|
||||
false,
|
||||
);
|
||||
assert!(adapter.is_allowed_room("!room1:matrix.org"));
|
||||
assert!(!adapter.is_allowed_room("!room2:matrix.org"));
|
||||
@@ -481,6 +484,7 @@ mod tests {
|
||||
"@bot:matrix.org".to_string(),
|
||||
"token".to_string(),
|
||||
vec![],
|
||||
false,
|
||||
);
|
||||
assert!(open.is_allowed_room("!any:matrix.org"));
|
||||
}
|
||||
|
||||
@@ -1861,6 +1861,9 @@ pub struct MatrixConfig {
|
||||
pub allowed_rooms: Vec<String>,
|
||||
/// Default agent name to route messages to.
|
||||
pub default_agent: Option<String>,
|
||||
/// Whether to auto-accept room invites (default: false).
|
||||
#[serde(default)]
|
||||
pub auto_accept_invites: bool,
|
||||
/// Per-channel behavior overrides.
|
||||
#[serde(default)]
|
||||
pub overrides: ChannelOverrides,
|
||||
@@ -1874,6 +1877,7 @@ impl Default for MatrixConfig {
|
||||
access_token_env: "MATRIX_ACCESS_TOKEN".to_string(),
|
||||
allowed_rooms: vec![],
|
||||
default_agent: None,
|
||||
auto_accept_invites: false,
|
||||
overrides: ChannelOverrides::default(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user