mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-15 21:26:50 +00:00
Refactor join, alias services
Split knock, user register from api into services Fix autojoin not working with v12 rooms Fix 'm.login.registration_token/validity' for reloaded registration tokens Change join servers order Move autojoin for ldap
This commit is contained in:
1 parent
959c559bd8
commit
7115fb2796
25 files changed
+1152
-1333
No files matched your search
@@ -1,6 +1,6 @@
|
||||
use futures::FutureExt;
|
||||
use ruma::{OwnedUserId, UserId};
|
||||
use tuwunel_core::{Err, Result, debug, error, info, warn};
|
||||
use tuwunel_core::{Err, Result, debug};
|
||||
use tuwunel_service::Services;
|
||||
|
||||
use super::password_login;
|
||||
@@ -51,69 +51,8 @@ pub(super) async fn ldap_login(
|
||||
if !services.users.exists(lowercased_user_id).await {
|
||||
services
|
||||
.users
|
||||
.create(lowercased_user_id, Some("*"), Some("ldap"))
|
||||
.full_register(lowercased_user_id, Some("*"), Some("ldap"), None, false, false)
|
||||
.await?;
|
||||
|
||||
// Auto-join rooms for newly created LDAP users
|
||||
if !services.server.config.auto_join_rooms.is_empty() {
|
||||
for room in &services.server.config.auto_join_rooms {
|
||||
let Ok(room_id) = services.alias.maybe_resolve(room).await else {
|
||||
error!(
|
||||
"Failed to resolve room alias to room ID when attempting to auto join \
|
||||
{room}, skipping"
|
||||
);
|
||||
continue;
|
||||
};
|
||||
|
||||
if !services
|
||||
.state_cache
|
||||
.server_in_room(services.globals.server_name(), &room_id)
|
||||
.await
|
||||
{
|
||||
warn!(
|
||||
"Skipping room {room} to automatically join as we have never joined \
|
||||
before."
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(room_server_name) = room.server_name() {
|
||||
let state_lock = services.state.mutex.lock(&room_id).await;
|
||||
|
||||
match services
|
||||
.membership
|
||||
.join(
|
||||
lowercased_user_id,
|
||||
&room_id,
|
||||
Some("Automatically joining this room upon first login".to_owned()),
|
||||
&[
|
||||
services.globals.server_name().to_owned(),
|
||||
room_server_name.to_owned(),
|
||||
],
|
||||
&None,
|
||||
&state_lock,
|
||||
)
|
||||
.boxed()
|
||||
.await
|
||||
{
|
||||
| Err(e) => {
|
||||
// don't return this error so we don't fail logins
|
||||
error!(
|
||||
"Failed to automatically join room {room} for user \
|
||||
{lowercased_user_id}: {e}"
|
||||
);
|
||||
},
|
||||
| _ => {
|
||||
info!(
|
||||
"Automatically joined room {room} for user {lowercased_user_id}"
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
drop(state_lock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let is_tuwunel_admin = services
|
||||
|
||||
Reference in new issue
Block a user