mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-20 23:47:33 +00:00
chore: Clippy fixes
This commit is contained in:
24 files changed
+32
-82
No files matched your search
@@ -2,6 +2,7 @@
|
||||
#![allow(clippy::wildcard_imports)]
|
||||
#![allow(clippy::enum_glob_use)]
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
#![allow(clippy::large_unopt_stack_frames, reason = "very large Subcommand macro expansions")]
|
||||
|
||||
conduwuit_macros::introspect_crate! {}
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@ use ruma::{
|
||||
OneTimeKeyAlgorithm, OwnedDeviceId, OwnedUserId, UserId,
|
||||
api::{
|
||||
client::keys::{
|
||||
claim_keys, get_key_changes, get_keys, upload_keys,
|
||||
upload_signatures::{self},
|
||||
claim_keys, get_key_changes, get_keys, upload_keys, upload_signatures,
|
||||
upload_signing_keys,
|
||||
},
|
||||
federation,
|
||||
|
||||
@@ -16,10 +16,7 @@ use futures::{FutureExt, StreamExt};
|
||||
use ruma::{
|
||||
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedServerName,
|
||||
OwnedUserId, RoomId, UserId,
|
||||
api::{
|
||||
client::knock::knock_room,
|
||||
federation::{self},
|
||||
},
|
||||
api::{client::knock::knock_room, federation},
|
||||
canonical_json::to_canonical_value,
|
||||
events::{
|
||||
StateEventType,
|
||||
|
||||
@@ -10,10 +10,7 @@ use conduwuit::{
|
||||
use futures::{FutureExt, StreamExt, pin_mut};
|
||||
use ruma::{
|
||||
CanonicalJsonObject, CanonicalJsonValue, OwnedServerName, RoomId, UserId,
|
||||
api::{
|
||||
client::membership::leave_room,
|
||||
federation::{self},
|
||||
},
|
||||
api::{client::membership::leave_room, federation},
|
||||
events::{
|
||||
StateEventType,
|
||||
room::member::{MembershipState, RoomMemberEventContent},
|
||||
|
||||
@@ -9,7 +9,7 @@ use conduwuit::{
|
||||
use futures::{FutureExt, StreamExt, future::join};
|
||||
use ruma::{
|
||||
api::client::membership::{
|
||||
get_member_events::{self},
|
||||
get_member_events,
|
||||
joined_members::{self, v3::RoomMember},
|
||||
},
|
||||
events::{
|
||||
|
||||
@@ -77,7 +77,7 @@ struct FullCreationContent {
|
||||
/// - Send events listed in initial state
|
||||
/// - Send events implied by `name` and `topic`
|
||||
/// - Send invite events
|
||||
#[allow(clippy::large_stack_frames)]
|
||||
#[allow(clippy::large_unopt_stack_frames)]
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
pub(crate) async fn create_room_route(
|
||||
State(services): State<crate::State>,
|
||||
|
||||
@@ -94,8 +94,7 @@ pub(crate) async fn room_initial_sync_route(
|
||||
.first()
|
||||
.map(at!(0))
|
||||
.as_ref()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or_default();
|
||||
.map_or_default(ToString::to_string);
|
||||
let start = events.last().map(at!(0)).as_ref().map(ToString::to_string);
|
||||
|
||||
let chunk = events
|
||||
|
||||
@@ -787,8 +787,7 @@ async fn build_room_summary(
|
||||
|
||||
Ok(Some(assign!(RoomSummary::new(), {
|
||||
heroes: heroes
|
||||
.map(|heroes| heroes.into_iter().collect())
|
||||
.unwrap_or_default(),
|
||||
.map_or_default(|heroes| heroes.into_iter().collect()),
|
||||
joined_member_count: Some(ruma_from_u64(joined_member_count)),
|
||||
invited_member_count: Some(ruma_from_u64(invited_member_count)),
|
||||
})))
|
||||
|
||||
@@ -5,9 +5,7 @@ use conduwuit::{
|
||||
};
|
||||
use futures::{FutureExt, StreamExt, pin_mut};
|
||||
use ruma::{
|
||||
api::client::user_directory::search_users::{self},
|
||||
assign,
|
||||
events::room::join_rules::JoinRule,
|
||||
api::client::user_directory::search_users, assign, events::room::join_rules::JoinRule,
|
||||
};
|
||||
|
||||
use crate::Ruma;
|
||||
|
||||
@@ -69,7 +69,7 @@ pub(crate) async fn create_join_event_template_route(
|
||||
.get_member(&body.room_id, &body.user_id)
|
||||
.await
|
||||
.ok()
|
||||
.map_or_else(|| MembershipState::Leave, |content| content.membership);
|
||||
.map_or(MembershipState::Leave, |content| content.membership);
|
||||
|
||||
let join_authorized_via_users_server: Option<OwnedUserId> = {
|
||||
if matches!(
|
||||
|
||||
@@ -76,8 +76,7 @@ impl super::Engine {
|
||||
.config
|
||||
.database_backup_path
|
||||
.clone()
|
||||
.map(PathBuf::into_os_string)
|
||||
.unwrap_or_default();
|
||||
.map_or_default(PathBuf::into_os_string);
|
||||
|
||||
if path.is_empty() {
|
||||
return Err!(Config("database_backup_path", "Configure path to enable backups"));
|
||||
|
||||
@@ -22,7 +22,7 @@ use hyper_util::{
|
||||
use tokio::{
|
||||
fs,
|
||||
net::{UnixListener, UnixStream, unix::SocketAddr},
|
||||
sync::broadcast::{self},
|
||||
sync::broadcast,
|
||||
task::JoinSet,
|
||||
time::{Duration, sleep},
|
||||
};
|
||||
|
||||
@@ -379,7 +379,7 @@ fn get_dns_resolver(server: &Arc<Server>) -> Result<Arc<TokioResolver>> {
|
||||
info!(?nameservers, "Resolved nameservers for DNS client");
|
||||
|
||||
for sys_conf in nameservers {
|
||||
let mut ns = sys_conf.clone();
|
||||
let mut ns = sys_conf;
|
||||
|
||||
if config.query_over_tcp_only {
|
||||
ns.connections = vec![ConnectionConfig::tcp()];
|
||||
|
||||
@@ -182,26 +182,11 @@ impl Data {
|
||||
let mut value = Vec::<u8>::new();
|
||||
value.extend_from_slice(×tamp.as_secs().to_be_bytes());
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(
|
||||
data.title
|
||||
.as_ref()
|
||||
.map(String::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
value.extend_from_slice(data.title.as_ref().map_or_default(String::as_bytes));
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(
|
||||
data.description
|
||||
.as_ref()
|
||||
.map(String::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
value.extend_from_slice(data.description.as_ref().map_or_default(String::as_bytes));
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(
|
||||
data.image
|
||||
.as_ref()
|
||||
.map(String::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
value.extend_from_slice(data.image.as_ref().map_or_default(String::as_bytes));
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(&data.image_size.unwrap_or(0).to_be_bytes());
|
||||
value.push(0xFF);
|
||||
@@ -209,12 +194,7 @@ impl Data {
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(&data.image_height.unwrap_or(0).to_be_bytes());
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(
|
||||
data.video
|
||||
.as_ref()
|
||||
.map(String::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
value.extend_from_slice(data.video.as_ref().map_or_default(String::as_bytes));
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(&data.video_size.unwrap_or(0).to_be_bytes());
|
||||
value.push(0xFF);
|
||||
@@ -222,12 +202,7 @@ impl Data {
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(&data.video_height.unwrap_or(0).to_be_bytes());
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(
|
||||
data.audio
|
||||
.as_ref()
|
||||
.map(String::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
value.extend_from_slice(data.audio.as_ref().map_or_default(String::as_bytes));
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(&data.audio_size.unwrap_or(0).to_be_bytes());
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
ffi::{OsStr, OsString},
|
||||
fs::{self},
|
||||
fs,
|
||||
path::PathBuf,
|
||||
sync::Arc,
|
||||
time::Instant,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#![type_length_limit = "8192"]
|
||||
#![recursion_limit = "256"]
|
||||
#![allow(refining_impl_trait)]
|
||||
|
||||
extern crate conduwuit_core as conduwuit;
|
||||
|
||||
@@ -153,7 +153,7 @@ impl Service {
|
||||
.get_member(room_id, sender_user)
|
||||
.await
|
||||
.ok()
|
||||
.map_or_else(|| MembershipState::Leave, |content| content.membership)
|
||||
.map_or(MembershipState::Leave, |content| content.membership)
|
||||
} else {
|
||||
MembershipState::Leave
|
||||
};
|
||||
|
||||
@@ -8,10 +8,7 @@ use conduwuit::{
|
||||
utils::{self, IterStream, ReadyExt},
|
||||
};
|
||||
use database::{Deserialized, Get, Map, Qry};
|
||||
use futures::{
|
||||
Stream, StreamExt,
|
||||
stream::{self},
|
||||
};
|
||||
use futures::{Stream, StreamExt, stream};
|
||||
use ruma::{EventId, OwnedEventId, RoomId, events::StateEventType};
|
||||
use serde::Deserialize;
|
||||
|
||||
|
||||
@@ -264,14 +264,11 @@ impl Service {
|
||||
.compress_state_event(shortstatekey, &new_pdu.event_id)
|
||||
.await;
|
||||
|
||||
let replaces = states_parents
|
||||
.last()
|
||||
.map(|info| {
|
||||
info.full_state
|
||||
.iter()
|
||||
.find(|bytes| bytes.starts_with(&shortstatekey.to_be_bytes()))
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let replaces = states_parents.last().map_or_default(|info| {
|
||||
info.full_state
|
||||
.iter()
|
||||
.find(|bytes| bytes.starts_with(&shortstatekey.to_be_bytes()))
|
||||
});
|
||||
|
||||
if Some(&new) == replaces {
|
||||
return Ok(previous_shortstatehash.expect("must exist"));
|
||||
|
||||
@@ -745,7 +745,7 @@ impl Service {
|
||||
.get_member(room_id, querying_user)
|
||||
.await
|
||||
.ok()
|
||||
.map_or_else(|| MembershipState::Leave, |content| content.membership);
|
||||
.map_or(MembershipState::Leave, |content| content.membership);
|
||||
|
||||
if matches!(membership, MembershipState::Join | MembershipState::Invite) {
|
||||
return true;
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
use conduwuit::config::experiments::ToggledExperiment;
|
||||
use conduwuit_core::{
|
||||
Err, Result, err,
|
||||
matrix::event::Event,
|
||||
utils::{self},
|
||||
warn,
|
||||
};
|
||||
use conduwuit_core::{Err, Result, err, matrix::event::Event, utils, warn};
|
||||
use ruma::{EventId, events::room::encrypted::Relation, signatures::content_hash};
|
||||
|
||||
use super::{ExtractBody, ExtractRelatesTo};
|
||||
|
||||
@@ -101,8 +101,7 @@ impl super::Service {
|
||||
.trusted_servers
|
||||
.iter()
|
||||
.find(|n| n.server_name() == notary)
|
||||
.map(|nk| nk.verify_keys().to_owned())
|
||||
.unwrap_or_default();
|
||||
.map_or_default(|nk| nk.verify_keys().to_owned());
|
||||
let keys = self
|
||||
.services
|
||||
.sending
|
||||
|
||||
@@ -143,7 +143,7 @@ impl Service {
|
||||
) {
|
||||
let mut key = user_id.as_bytes().to_vec();
|
||||
key.push(0xFF);
|
||||
key.extend_from_slice(device_id.map(DeviceId::as_bytes).unwrap_or_default());
|
||||
key.extend_from_slice(device_id.map_or_default(DeviceId::as_bytes));
|
||||
key.push(0xFF);
|
||||
key.extend_from_slice(txn_id.as_bytes());
|
||||
|
||||
|
||||
@@ -9,10 +9,7 @@ pub(super) mod remote;
|
||||
use std::{mem, sync::Arc};
|
||||
|
||||
pub use account::{AccessTokenStatus, AccountStatus};
|
||||
use conduwuit::{
|
||||
Err, Error, Result, err,
|
||||
utils::{self},
|
||||
};
|
||||
use conduwuit::{Err, Error, Result, err, utils};
|
||||
use database::Map;
|
||||
pub use device::DeviceToken;
|
||||
pub use profile::ProfileFieldChange;
|
||||
|
||||
Reference in new issue
Block a user