1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-08-16 18:01:35 +00:00

make_join delegation

This commit is contained in:
avdb13 2024-07-03 07:51:12 +02:00
parent 2089ca8e3c
commit 7e54066023
2 changed files with 18 additions and 15 deletions

View file

@ -293,6 +293,7 @@ pub async fn register_route(body: Ruma<register::v3::Request>) -> Result<registe
} }
} }
let _user_id = user_id.clone();
let default_rooms = services().globals.default_rooms().await?; let default_rooms = services().globals.default_rooms().await?;
let servers: Vec<_> = default_rooms let servers: Vec<_> = default_rooms
.iter() .iter()
@ -301,9 +302,10 @@ pub async fn register_route(body: Ruma<register::v3::Request>) -> Result<registe
.map(Into::into) .map(Into::into)
.collect(); .collect();
tokio::spawn(async move {
for room_id in default_rooms { for room_id in default_rooms {
if let Err(e) = join_room_by_id_helper( if let Err(e) = join_room_by_id_helper(
Some(&user_id), Some(&_user_id),
room_id, room_id,
Some("All men are equal before fish.".to_owned()), Some("All men are equal before fish.".to_owned()),
&servers, &servers,
@ -314,6 +316,7 @@ pub async fn register_route(body: Ruma<register::v3::Request>) -> Result<registe
warn!("Failed to join default room: {}", e); warn!("Failed to join default room: {}", e);
} }
} }
});
} }
Ok(register::v3::Response { Ok(register::v3::Response {

View file

@ -10,7 +10,7 @@ use tokio::sync::OnceCell;
use crate::api::server_server::DestinationResponse; use crate::api::server_server::DestinationResponse;
use crate::{services, Config, Error, Result}; use crate::{services, Config, Error, Result};
use futures_util::{FutureExt, TryFutureExt}; use futures_util::FutureExt;
use hickory_resolver::TokioAsyncResolver; use hickory_resolver::TokioAsyncResolver;
use hyper_util::client::legacy::connect::dns::{GaiResolver, Name as HyperName}; use hyper_util::client::legacy::connect::dns::{GaiResolver, Name as HyperName};
use reqwest::dns::{Addrs, Name, Resolve, Resolving}; use reqwest::dns::{Addrs, Name, Resolve, Resolving};
@ -519,7 +519,7 @@ impl Service {
for mut alias_or_id in self.config.default_rooms.iter().cloned() { for mut alias_or_id in self.config.default_rooms.iter().cloned() {
// anything that does not start '!' should be considered an alias // anything that does not start '!' should be considered an alias
// empty strings are ignored // empty strings are ignored
let room_id = if Some('!') == alias_or_id.chars().next() { let room_id = if alias_or_id.starts_with('!') {
if alias_or_id.split_once(':').is_none() { if alias_or_id.split_once(':').is_none() {
alias_or_id = format!("{}:{}", alias_or_id, self.config.server_name); alias_or_id = format!("{}:{}", alias_or_id, self.config.server_name);
} }
@ -546,7 +546,7 @@ impl Service {
Error::bad_config("Invalid room alias for join-by-default rooms.") Error::bad_config("Invalid room alias for join-by-default rooms.")
})?; })?;
if room_alias.server_name() == &self.config.server_name { if room_alias.server_name() == self.config.server_name {
services() services()
.rooms .rooms
.alias .alias