mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-09 13:53:03 +02:00
style(hydra): Satisfy clippy's twisted and confusing demands
This commit is contained in:
parent
d221491377
commit
ef42638f3c
9 changed files with 32 additions and 15 deletions
|
@ -179,7 +179,11 @@ pub(super) async fn create_user(&self, username: String, password: Option<String
|
||||||
.await
|
.await
|
||||||
.is_ok_and(is_equal_to!(1))
|
.is_ok_and(is_equal_to!(1))
|
||||||
{
|
{
|
||||||
self.services.admin.make_user_admin(&user_id).await?;
|
self.services
|
||||||
|
.admin
|
||||||
|
.make_user_admin(&user_id)
|
||||||
|
.boxed()
|
||||||
|
.await?;
|
||||||
warn!("Granting {user_id} admin privileges as the first user");
|
warn!("Granting {user_id} admin privileges as the first user");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -217,7 +221,9 @@ pub(super) async fn deactivate(&self, no_leave_rooms: bool, user_id: String) ->
|
||||||
.collect()
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
full_user_deactivate(self.services, &user_id, &all_joined_rooms).await?;
|
full_user_deactivate(self.services, &user_id, &all_joined_rooms)
|
||||||
|
.boxed()
|
||||||
|
.await?;
|
||||||
update_displayname(self.services, &user_id, None, &all_joined_rooms).await;
|
update_displayname(self.services, &user_id, None, &all_joined_rooms).await;
|
||||||
update_avatar_url(self.services, &user_id, None, None, &all_joined_rooms).await;
|
update_avatar_url(self.services, &user_id, None, None, &all_joined_rooms).await;
|
||||||
leave_all_rooms(self.services, &user_id).await;
|
leave_all_rooms(self.services, &user_id).await;
|
||||||
|
@ -376,7 +382,9 @@ pub(super) async fn deactivate_all(&self, no_leave_rooms: bool, force: bool) ->
|
||||||
.collect()
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
full_user_deactivate(self.services, &user_id, &all_joined_rooms).await?;
|
full_user_deactivate(self.services, &user_id, &all_joined_rooms)
|
||||||
|
.boxed()
|
||||||
|
.await?;
|
||||||
update_displayname(self.services, &user_id, None, &all_joined_rooms).await;
|
update_displayname(self.services, &user_id, None, &all_joined_rooms).await;
|
||||||
update_avatar_url(self.services, &user_id, None, None, &all_joined_rooms)
|
update_avatar_url(self.services, &user_id, None, None, &all_joined_rooms)
|
||||||
.await;
|
.await;
|
||||||
|
@ -776,7 +784,11 @@ pub(super) async fn make_user_admin(&self, user_id: String) -> Result {
|
||||||
"Parsed user_id must be a local user"
|
"Parsed user_id must be a local user"
|
||||||
);
|
);
|
||||||
|
|
||||||
self.services.admin.make_user_admin(&user_id).await?;
|
self.services
|
||||||
|
.admin
|
||||||
|
.make_user_admin(&user_id)
|
||||||
|
.boxed()
|
||||||
|
.await?;
|
||||||
|
|
||||||
self.write_str(&format!("{user_id} has been granted admin privileges.",))
|
self.write_str(&format!("{user_id} has been granted admin privileges.",))
|
||||||
.await
|
.await
|
||||||
|
|
|
@ -505,7 +505,7 @@ pub(crate) async fn register_route(
|
||||||
.await
|
.await
|
||||||
.is_ok_and(is_equal_to!(1))
|
.is_ok_and(is_equal_to!(1))
|
||||||
{
|
{
|
||||||
services.admin.make_user_admin(&user_id).await?;
|
services.admin.make_user_admin(&user_id).boxed().await?;
|
||||||
warn!("Granting {user_id} admin privileges as the first user");
|
warn!("Granting {user_id} admin privileges as the first user");
|
||||||
} else if services.config.suspend_on_register {
|
} else if services.config.suspend_on_register {
|
||||||
// This is not an admin, suspend them.
|
// This is not an admin, suspend them.
|
||||||
|
|
|
@ -49,6 +49,7 @@ use crate::{Ruma, client::invite_helper};
|
||||||
/// - Send events implied by `name` and `topic`
|
/// - Send events implied by `name` and `topic`
|
||||||
/// - Send invite events
|
/// - Send invite events
|
||||||
#[allow(clippy::large_stack_frames)]
|
#[allow(clippy::large_stack_frames)]
|
||||||
|
#[allow(clippy::cognitive_complexity)]
|
||||||
pub(crate) async fn create_room_route(
|
pub(crate) async fn create_room_route(
|
||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<create_room::v3::Request>,
|
body: Ruma<create_room::v3::Request>,
|
||||||
|
|
|
@ -145,9 +145,9 @@ pub(super) async fn ldap_login(
|
||||||
let is_conduwuit_admin = services.admin.user_is_admin(lowercased_user_id).await;
|
let is_conduwuit_admin = services.admin.user_is_admin(lowercased_user_id).await;
|
||||||
|
|
||||||
if is_ldap_admin && !is_conduwuit_admin {
|
if is_ldap_admin && !is_conduwuit_admin {
|
||||||
services.admin.make_user_admin(lowercased_user_id).await?;
|
Box::pin(services.admin.make_user_admin(lowercased_user_id)).await?;
|
||||||
} else if !is_ldap_admin && is_conduwuit_admin {
|
} else if !is_ldap_admin && is_conduwuit_admin {
|
||||||
services.admin.revoke_admin(lowercased_user_id).await?;
|
Box::pin(services.admin.revoke_admin(lowercased_user_id)).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(user_id)
|
Ok(user_id)
|
||||||
|
|
|
@ -117,7 +117,7 @@ impl Event for Pdu {
|
||||||
if let Some(room_id) = &self.room_id {
|
if let Some(room_id) = &self.room_id {
|
||||||
room_id.clone()
|
room_id.clone()
|
||||||
} else {
|
} else {
|
||||||
let constructed_hash = "!".to_owned() + &self.event_id.as_str()[1..];
|
let constructed_hash = self.event_id.as_str().replace('$', "!");
|
||||||
RoomId::parse(&constructed_hash)
|
RoomId::parse(&constructed_hash)
|
||||||
.expect("event ID can be indexed")
|
.expect("event ID can be indexed")
|
||||||
.to_owned()
|
.to_owned()
|
||||||
|
@ -182,7 +182,7 @@ impl Event for &Pdu {
|
||||||
if let Some(room_id) = &self.room_id {
|
if let Some(room_id) = &self.room_id {
|
||||||
room_id.clone()
|
room_id.clone()
|
||||||
} else {
|
} else {
|
||||||
let constructed_hash = "!".to_owned() + &self.event_id.as_str()[1..];
|
let constructed_hash = self.event_id.as_str().replace('$', "!");
|
||||||
RoomId::parse(&constructed_hash)
|
RoomId::parse(&constructed_hash)
|
||||||
.expect("event ID can be indexed")
|
.expect("event ID can be indexed")
|
||||||
.to_owned()
|
.to_owned()
|
||||||
|
|
|
@ -153,6 +153,7 @@ pub fn auth_types_for_event(
|
||||||
event_id = incoming_event.event_id().as_str(),
|
event_id = incoming_event.event_id().as_str(),
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
|
#[allow(clippy::suspicious_operation_groupings)]
|
||||||
pub async fn auth_check<E, F, Fut>(
|
pub async fn auth_check<E, F, Fut>(
|
||||||
room_version: &RoomVersion,
|
room_version: &RoomVersion,
|
||||||
incoming_event: &E,
|
incoming_event: &E,
|
||||||
|
|
|
@ -425,6 +425,7 @@ impl Service {
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
self.handle_response_error(e, room_id, user_id, &state_lock)
|
self.handle_response_error(e, room_id, user_id, &state_lock)
|
||||||
|
.boxed()
|
||||||
.await
|
.await
|
||||||
.unwrap_or_else(default_log);
|
.unwrap_or_else(default_log);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ use crate::{appservice::NamespaceRegex, rooms::state_compressor::CompressedState
|
||||||
/// the server that sent the event.
|
/// the server that sent the event.
|
||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
#[tracing::instrument(level = "debug", skip_all)]
|
#[tracing::instrument(level = "debug", skip_all)]
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub async fn append_incoming_pdu<'a, Leaves>(
|
pub async fn append_incoming_pdu<'a, Leaves>(
|
||||||
&'a self,
|
&'a self,
|
||||||
pdu: &'a PduEvent,
|
pdu: &'a PduEvent,
|
||||||
|
|
|
@ -32,12 +32,13 @@ pub async fn create_hash_and_sign_event(
|
||||||
_mutex_lock: &RoomMutexGuard, /* Take mutex guard to make sure users get the room
|
_mutex_lock: &RoomMutexGuard, /* Take mutex guard to make sure users get the room
|
||||||
* state mutex */
|
* state mutex */
|
||||||
) -> Result<(PduEvent, CanonicalJsonObject)> {
|
) -> Result<(PduEvent, CanonicalJsonObject)> {
|
||||||
|
#[allow(clippy::boxed_local)]
|
||||||
fn from_evt(
|
fn from_evt(
|
||||||
room_id: OwnedRoomId,
|
room_id: OwnedRoomId,
|
||||||
event_type: TimelineEventType,
|
event_type: &TimelineEventType,
|
||||||
content: Box<RawValue>,
|
content: &RawValue,
|
||||||
) -> Result<RoomVersionId> {
|
) -> Result<RoomVersionId> {
|
||||||
if event_type == TimelineEventType::RoomCreate {
|
if event_type == &TimelineEventType::RoomCreate {
|
||||||
let content: RoomCreateEventContent = serde_json::from_str(content.get())?;
|
let content: RoomCreateEventContent = serde_json::from_str(content.get())?;
|
||||||
Ok(content.room_version)
|
Ok(content.room_version)
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,11 +63,11 @@ pub async fn create_hash_and_sign_event(
|
||||||
.state
|
.state
|
||||||
.get_room_version(room_id)
|
.get_room_version(room_id)
|
||||||
.await
|
.await
|
||||||
.or_else(|_| from_evt(room_id.to_owned(), event_type.clone(), content.clone()))?,
|
.or_else(|_| from_evt(room_id.to_owned(), &event_type.clone(), &content.clone()))?,
|
||||||
| None => from_evt(
|
| None => from_evt(
|
||||||
RoomId::new(self.services.globals.server_name()),
|
RoomId::new(self.services.globals.server_name()),
|
||||||
event_type.clone(),
|
&event_type.clone(),
|
||||||
content.clone(),
|
&content.clone(),
|
||||||
)?,
|
)?,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue