refactor: remove unecessery async
This commit is contained in:
parent
98c7b89fca
commit
a6da294c55
3 changed files with 11 additions and 20 deletions
|
@ -907,7 +907,6 @@ async fn join_room_by_id_helper(
|
|||
.rooms
|
||||
.state_accessor
|
||||
.user_can_invite(room_id, &user, sender_user, &state_lock)
|
||||
.await
|
||||
.unwrap_or(false)
|
||||
{
|
||||
auth_user = Some(user);
|
||||
|
|
|
@ -1533,7 +1533,7 @@ pub async fn create_join_event_template_route(
|
|||
})
|
||||
.transpose()?;
|
||||
|
||||
let join_authorized_via_users_server = || async {
|
||||
let join_authorized_via_users_server = || {
|
||||
let join_rules_event_content = join_rules_event_content?;
|
||||
|
||||
if !services()
|
||||
|
@ -1578,28 +1578,20 @@ pub async fn create_join_event_template_route(
|
|||
.unwrap_or(false)
|
||||
})
|
||||
{
|
||||
let members: Vec<_> = services()
|
||||
let auth_user = services()
|
||||
.rooms
|
||||
.state_cache
|
||||
.room_members(&body.room_id)
|
||||
.filter_map(Result::ok)
|
||||
.filter(|user| user.server_name() == services().globals.server_name())
|
||||
.collect();
|
||||
.find(|user| {
|
||||
services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
.user_can_invite(&body.room_id, user, &body.user_id, &state_lock)
|
||||
.unwrap_or(false)
|
||||
});
|
||||
|
||||
let mut auth_user = None;
|
||||
|
||||
for user in members {
|
||||
if services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
.user_can_invite(&body.room_id, &user, &body.user_id, &state_lock)
|
||||
.await
|
||||
.unwrap_or(false)
|
||||
{
|
||||
auth_user = Some(user);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if auth_user.is_some() {
|
||||
Ok(auth_user).transpose()
|
||||
} else {
|
||||
|
@ -1616,7 +1608,7 @@ pub async fn create_join_event_template_route(
|
|||
}
|
||||
};
|
||||
|
||||
let join_authorized_via_users_server = join_authorized_via_users_server().await.transpose()?;
|
||||
let join_authorized_via_users_server = join_authorized_via_users_server().transpose()?;
|
||||
|
||||
let room_version_id = services().rooms.state.get_room_version(&body.room_id)?;
|
||||
if !body.ver.contains(&room_version_id) {
|
||||
|
|
|
@ -305,7 +305,7 @@ impl Service {
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn user_can_invite(
|
||||
pub fn user_can_invite(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
sender: &UserId,
|
||||
|
|
Loading…
Reference in a new issue