mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
enable dead_code lint
And delete all the dead code. And add some cfgs for feature-specific items.
This commit is contained in:
parent
d748544f0e
commit
2ff08c9fc4
8 changed files with 6 additions and 52 deletions
|
|
@ -13,9 +13,6 @@ unused_import_braces = "warn"
|
||||||
unused_macro_rules = "warn"
|
unused_macro_rules = "warn"
|
||||||
unused_qualifications = "warn"
|
unused_qualifications = "warn"
|
||||||
|
|
||||||
# TODO: Remove these
|
|
||||||
dead_code = "allow"
|
|
||||||
|
|
||||||
# Keep alphabetically sorted
|
# Keep alphabetically sorted
|
||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
assertions_on_result_states = "warn"
|
assertions_on_result_states = "warn"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
use std::{collections::BTreeMap, iter::FromIterator};
|
use std::{collections::BTreeMap, iter::FromIterator};
|
||||||
|
|
||||||
use axum::{response::IntoResponse, Json};
|
use ruma::api::client::discovery::get_supported_versions;
|
||||||
use ruma::api::client::{discovery::get_supported_versions, error::ErrorKind};
|
|
||||||
|
|
||||||
use crate::{services, Error, Result, Ruma};
|
use crate::{Result, Ruma};
|
||||||
|
|
||||||
/// # `GET /_matrix/client/versions`
|
/// # `GET /_matrix/client/versions`
|
||||||
///
|
///
|
||||||
|
|
@ -33,18 +32,3 @@ pub(crate) async fn get_supported_versions_route(
|
||||||
|
|
||||||
Ok(resp)
|
Ok(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `GET /.well-known/matrix/client`
|
|
||||||
pub(crate) async fn well_known_client_route(
|
|
||||||
_body: Ruma<get_supported_versions::Request>,
|
|
||||||
) -> Result<impl IntoResponse> {
|
|
||||||
let client_url = match services().globals.well_known_client() {
|
|
||||||
Some(url) => url.clone(),
|
|
||||||
None => return Err(Error::BadRequest(ErrorKind::NotFound, "Not found.")),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Json(serde_json::json!({
|
|
||||||
"m.homeserver": {"base_url": client_url},
|
|
||||||
"org.matrix.msc3575.proxy": {"url": client_url}
|
|
||||||
})))
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ pub(crate) struct Config {
|
||||||
pub(crate) db_cache_capacity_mb: f64,
|
pub(crate) db_cache_capacity_mb: f64,
|
||||||
#[serde(default = "default_cache_capacity_modifier")]
|
#[serde(default = "default_cache_capacity_modifier")]
|
||||||
pub(crate) cache_capacity_modifier: f64,
|
pub(crate) cache_capacity_modifier: f64,
|
||||||
|
#[cfg(feature = "rocksdb")]
|
||||||
#[serde(default = "default_rocksdb_max_open_files")]
|
#[serde(default = "default_rocksdb_max_open_files")]
|
||||||
pub(crate) rocksdb_max_open_files: i32,
|
pub(crate) rocksdb_max_open_files: i32,
|
||||||
#[serde(default = "default_pdu_cache_capacity")]
|
#[serde(default = "default_pdu_cache_capacity")]
|
||||||
|
|
@ -52,7 +53,6 @@ pub(crate) struct Config {
|
||||||
pub(crate) allow_unstable_room_versions: bool,
|
pub(crate) allow_unstable_room_versions: bool,
|
||||||
#[serde(default = "default_default_room_version")]
|
#[serde(default = "default_default_room_version")]
|
||||||
pub(crate) default_room_version: RoomVersionId,
|
pub(crate) default_room_version: RoomVersionId,
|
||||||
pub(crate) well_known_client: Option<String>,
|
|
||||||
#[serde(default = "false_fn")]
|
#[serde(default = "false_fn")]
|
||||||
pub(crate) allow_jaeger: bool,
|
pub(crate) allow_jaeger: bool,
|
||||||
#[serde(default = "false_fn")]
|
#[serde(default = "false_fn")]
|
||||||
|
|
@ -222,6 +222,7 @@ fn default_cache_capacity_modifier() -> f64 {
|
||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rocksdb")]
|
||||||
fn default_rocksdb_max_open_files() -> i32 {
|
fn default_rocksdb_max_open_files() -> i32 {
|
||||||
1000
|
1000
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use futures_util::Future;
|
||||||
use regex::RegexSet;
|
use regex::RegexSet;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::appservice::{Namespace, Registration},
|
api::appservice::{Namespace, Registration},
|
||||||
RoomAliasId, RoomId, UserId,
|
RoomAliasId, UserId,
|
||||||
};
|
};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
|
|
@ -207,14 +207,6 @@ impl Service {
|
||||||
.any(|info| info.aliases.is_exclusive_match(alias.as_str()))
|
.any(|info| info.aliases.is_exclusive_match(alias.as_str()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if a given room id matches any exclusive appservice regex
|
|
||||||
pub(crate) async fn is_exclusive_room_id(&self, room_id: &RoomId) -> bool {
|
|
||||||
self.read()
|
|
||||||
.await
|
|
||||||
.values()
|
|
||||||
.any(|info| info.rooms.is_exclusive_match(room_id.as_str()))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn read(
|
pub(crate) fn read(
|
||||||
&self,
|
&self,
|
||||||
) -> impl Future<Output = tokio::sync::RwLockReadGuard<'_, BTreeMap<String, RegistrationInfo>>>
|
) -> impl Future<Output = tokio::sync::RwLockReadGuard<'_, BTreeMap<String, RegistrationInfo>>>
|
||||||
|
|
|
||||||
|
|
@ -399,10 +399,6 @@ impl Service {
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn well_known_client(&self) -> &Option<String> {
|
|
||||||
&self.config.well_known_client
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn shutdown(&self) {
|
pub(crate) fn shutdown(&self) {
|
||||||
self.shutdown.store(true, atomic::Ordering::Relaxed);
|
self.shutdown.store(true, atomic::Ordering::Relaxed);
|
||||||
// On shutdown
|
// On shutdown
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ mod data;
|
||||||
pub(crate) use data::Data;
|
pub(crate) use data::Data;
|
||||||
use ruma::{CanonicalJsonObject, EventId};
|
use ruma::{CanonicalJsonObject, EventId};
|
||||||
|
|
||||||
use crate::{PduEvent, Result};
|
use crate::Result;
|
||||||
|
|
||||||
pub(crate) struct Service {
|
pub(crate) struct Service {
|
||||||
pub(crate) db: &'static dyn Data,
|
pub(crate) db: &'static dyn Data,
|
||||||
|
|
@ -18,11 +18,6 @@ impl Service {
|
||||||
self.db.get_outlier_pdu_json(event_id)
|
self.db.get_outlier_pdu_json(event_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the pdu from the outlier tree.
|
|
||||||
pub(crate) fn get_pdu_outlier(&self, event_id: &EventId) -> Result<Option<PduEvent>> {
|
|
||||||
self.db.get_outlier_pdu(event_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Append the PDU as an outlier.
|
/// Append the PDU as an outlier.
|
||||||
#[tracing::instrument(skip(self, pdu))]
|
#[tracing::instrument(skip(self, pdu))]
|
||||||
pub(crate) fn add_pdu_outlier(
|
pub(crate) fn add_pdu_outlier(
|
||||||
|
|
|
||||||
|
|
@ -159,13 +159,6 @@ impl Service {
|
||||||
self.db.get_pdu_id(event_id)
|
self.db.get_pdu_id(event_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the pdu.
|
|
||||||
///
|
|
||||||
/// Checks the `eventid_outlierpdu` Tree if not found in the timeline.
|
|
||||||
pub(crate) fn get_non_outlier_pdu(&self, event_id: &EventId) -> Result<Option<PduEvent>> {
|
|
||||||
self.db.get_non_outlier_pdu(event_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the pdu.
|
/// Returns the pdu.
|
||||||
///
|
///
|
||||||
/// Checks the `eventid_outlierpdu` Tree if not found in the timeline.
|
/// Checks the `eventid_outlierpdu` Tree if not found in the timeline.
|
||||||
|
|
|
||||||
|
|
@ -397,10 +397,6 @@ impl Service {
|
||||||
.add_one_time_key(user_id, device_id, one_time_key_key, one_time_key_value)
|
.add_one_time_key(user_id, device_id, one_time_key_key, one_time_key_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn last_one_time_keys_update(&self, user_id: &UserId) -> Result<u64> {
|
|
||||||
self.db.last_one_time_keys_update(user_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn take_one_time_key(
|
pub(crate) fn take_one_time_key(
|
||||||
&self,
|
&self,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue