forked from mirror/grapevine
Compare commits
6 commits
custom
...
lambda/exp
Author | SHA1 | Date | |
---|---|---|---|
|
1a98d53977 | ||
|
11d3dfda30 | ||
|
971119318b | ||
|
f547797480 | ||
|
0c75e41a0b | ||
|
e43908d897 |
53 changed files with 214 additions and 260 deletions
|
@ -5,7 +5,6 @@ explicit_outlives_requirements = "warn"
|
|||
macro_use_extern_crate = "warn"
|
||||
missing_abi = "warn"
|
||||
noop_method_call = "warn"
|
||||
pointer_structural_match = "warn"
|
||||
single_use_lifetimes = "warn"
|
||||
unreachable_pub = "warn"
|
||||
unsafe_op_in_unsafe_fn = "warn"
|
||||
|
@ -17,9 +16,11 @@ unused_qualifications = "warn"
|
|||
|
||||
[workspace.lints.clippy]
|
||||
# Groups. Keep alphabetically sorted
|
||||
pedantic = "warn"
|
||||
pedantic = { level = "warn", priority = -1 }
|
||||
|
||||
# Lints. Keep alphabetically sorted
|
||||
allow_attributes = "warn"
|
||||
allow_attributes_without_reason = "warn"
|
||||
as_conversions = "warn"
|
||||
assertions_on_result_states = "warn"
|
||||
dbg_macro = "warn"
|
||||
|
@ -80,7 +81,7 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
# See also `rust-toolchain.toml`
|
||||
rust-version = "1.78.0"
|
||||
rust-version = "1.81.0"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
rust-manifest = {
|
||||
# Keep version in sync with rust-toolchain.toml
|
||||
url = "https://static.rust-lang.org/dist/channel-rust-1.78.0.toml";
|
||||
url = "https://static.rust-lang.org/dist/channel-rust-1.81.0.toml";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# If you're having trouble making the relevant changes, bug a maintainer.
|
||||
|
||||
[toolchain]
|
||||
channel = "1.78.0"
|
||||
channel = "1.81.0"
|
||||
components = [
|
||||
# For rust-analyzer
|
||||
"rust-src",
|
||||
|
|
|
@ -85,7 +85,7 @@ pub(crate) async fn get_register_available_route(
|
|||
/// - Creates a new account and populates it with default account data
|
||||
/// - If `inhibit_login` is false: Creates a device and returns `device_id` and
|
||||
/// `access_token`
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn register_route(
|
||||
body: Ar<register::v3::Request>,
|
||||
) -> Result<Ra<register::v3::Response>> {
|
||||
|
@ -316,8 +316,7 @@ pub(crate) async fn register_route(
|
|||
/// - Requires UIAA to verify user password
|
||||
/// - Changes the password of the sender user
|
||||
/// - The password hash is calculated using argon2 with 32 character salt, the
|
||||
/// plain password is
|
||||
/// not saved
|
||||
/// plain password is not saved
|
||||
///
|
||||
/// If `logout_devices` is true it does the following for each device except the
|
||||
/// sender device:
|
||||
|
|
|
@ -16,9 +16,8 @@ use crate::{services, Ar, Error, Ra, Result};
|
|||
/// Allows loading room history around an event.
|
||||
///
|
||||
/// - Only works if the user is joined (TODO: always allow, but only show events
|
||||
/// if the user was
|
||||
/// joined, depending on `history_visibility`)
|
||||
#[allow(clippy::too_many_lines)]
|
||||
/// if the user was joined, depending on `history_visibility`)
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn get_context_route(
|
||||
body: Ar<get_context::v3::Request>,
|
||||
) -> Result<Ra<get_context::v3::Response>> {
|
||||
|
|
|
@ -137,7 +137,7 @@ pub(crate) async fn get_room_visibility_route(
|
|||
}))
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn get_public_rooms_filtered_helper(
|
||||
server: Option<&ServerName>,
|
||||
limit: Option<UInt>,
|
||||
|
@ -267,7 +267,6 @@ pub(crate) async fn get_public_rooms_filtered_helper(
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[tracing::instrument]
|
||||
fn room_id_to_chunk(room_id: ruma::OwnedRoomId) -> Result<PublicRoomsChunk> {
|
||||
let canonical_alias = services()
|
||||
|
|
|
@ -284,7 +284,7 @@ pub(crate) async fn get_key_changes_route(
|
|||
}))
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
|
||||
sender_user: Option<&UserId>,
|
||||
device_keys_input: &BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>,
|
||||
|
|
|
@ -124,7 +124,7 @@ fn set_header_or_panic(
|
|||
/// # `GET /_matrix/media/r0/config`
|
||||
///
|
||||
/// Returns max upload size.
|
||||
#[allow(deprecated)] // unauthenticated media
|
||||
#[expect(deprecated, reason = "legacy media APIs")]
|
||||
pub(crate) async fn get_media_config_legacy_route(
|
||||
_body: Ar<legacy_media::get_media_config::v3::Request>,
|
||||
) -> Result<Ra<legacy_media::get_media_config::v3::Response>> {
|
||||
|
@ -196,7 +196,7 @@ impl From<bool> for AllowRemote {
|
|||
}
|
||||
|
||||
struct RemoteResponse {
|
||||
#[allow(unused)]
|
||||
#[expect(unused, reason = "placeholder for future spec changes")]
|
||||
metadata: authenticated_media_fed::ContentMetadata,
|
||||
content: authenticated_media_fed::Content,
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ async fn get_remote_content_via_federation_api(
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(deprecated)] // unauthenticated media
|
||||
#[expect(deprecated, reason = "legacy media APIs")]
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn get_remote_content_via_legacy_api(
|
||||
mxc: &MxcData<'_>,
|
||||
|
@ -365,7 +365,7 @@ pub(crate) async fn get_remote_content(
|
|||
/// Load media from our server or over federation.
|
||||
///
|
||||
/// - Only allows federation if `allow_remote` is true
|
||||
#[allow(deprecated)] // unauthenticated media
|
||||
#[expect(deprecated, reason = "legacy media APIs")]
|
||||
pub(crate) async fn get_content_legacy_route(
|
||||
body: Ar<legacy_media::get_content::v3::Request>,
|
||||
) -> Result<axum::response::Response> {
|
||||
|
@ -487,7 +487,7 @@ async fn get_content_route_ruma(
|
|||
/// Load media from our server or over federation, permitting desired filename.
|
||||
///
|
||||
/// - Only allows federation if `allow_remote` is true
|
||||
#[allow(deprecated)] // unauthenticated media
|
||||
#[expect(deprecated, reason = "legacy media APIs")]
|
||||
pub(crate) async fn get_content_as_filename_legacy_route(
|
||||
body: Ar<legacy_media::get_content_as_filename::v3::Request>,
|
||||
) -> Result<axum::response::Response> {
|
||||
|
@ -632,7 +632,7 @@ fn fix_thumbnail_headers(r: &mut axum::response::Response) {
|
|||
/// Load media thumbnail from our server or over federation.
|
||||
///
|
||||
/// - Only allows federation if `allow_remote` is true
|
||||
#[allow(deprecated)] // unauthenticated media
|
||||
#[expect(deprecated, reason = "legacy media APIs")]
|
||||
pub(crate) async fn get_content_thumbnail_legacy_route(
|
||||
body: Ar<legacy_media::get_content_thumbnail::v3::Request>,
|
||||
) -> Result<axum::response::Response> {
|
||||
|
@ -741,7 +741,7 @@ async fn get_remote_thumbnail_via_federation_api(
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(deprecated)] // unauthenticated media
|
||||
#[expect(deprecated, reason = "legacy media APIs")]
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn get_remote_thumbnail_via_legacy_api(
|
||||
server_name: &ruma::ServerName,
|
||||
|
|
|
@ -499,7 +499,6 @@ pub(crate) async fn joined_members_route(
|
|||
}))
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[tracing::instrument(skip(reason, _third_party_signed))]
|
||||
async fn join_room_by_id_helper(
|
||||
sender_user: Option<&UserId>,
|
||||
|
@ -1264,7 +1263,7 @@ async fn validate_and_add_event_id(
|
|||
Ok((event_id, value))
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn invite_helper(
|
||||
sender_user: &UserId,
|
||||
user_id: &UserId,
|
||||
|
@ -1570,7 +1569,7 @@ pub(crate) async fn leave_room(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
async fn remote_leave_room(user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
||||
let mut make_leave_response_and_server = Err(Error::BadServerResponse(
|
||||
"No server available to assist in leaving.",
|
||||
|
|
|
@ -117,9 +117,8 @@ pub(crate) async fn send_message_event_route(
|
|||
/// Allows paginating through room history.
|
||||
///
|
||||
/// - Only works if the user is joined (TODO: always allow, but only show events
|
||||
/// where the user was
|
||||
/// joined, depending on `history_visibility`)
|
||||
#[allow(clippy::too_many_lines)]
|
||||
/// where the user was joined, depending on `history_visibility`)
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn get_message_events_route(
|
||||
body: Ar<get_message_events::v3::Request>,
|
||||
) -> Result<Ra<get_message_events::v3::Response>> {
|
||||
|
|
|
@ -50,7 +50,7 @@ use crate::{
|
|||
/// - Send events listed in initial state
|
||||
/// - Send events implied by `name` and `topic`
|
||||
/// - Send invite events
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn create_room_route(
|
||||
body: Ar<create_room::v3::Request>,
|
||||
) -> Result<Ra<create_room::v3::Response>> {
|
||||
|
@ -585,7 +585,7 @@ pub(crate) async fn get_room_aliases_route(
|
|||
/// - Transfers some state events
|
||||
/// - Moves local aliases
|
||||
/// - Modifies old room power levels to prevent users from speaking
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn upgrade_room_route(
|
||||
body: Ar<upgrade_room::v3::Request>,
|
||||
) -> Result<Ra<upgrade_room::v3::Response>> {
|
||||
|
|
|
@ -22,7 +22,7 @@ use crate::{services, Ar, Error, Ra, Result};
|
|||
///
|
||||
/// - Only works if the user is currently joined to the room (TODO: Respect
|
||||
/// history visibility)
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn search_events_route(
|
||||
body: Ar<search_events::v3::Request>,
|
||||
) -> Result<Ra<search_events::v3::Response>> {
|
||||
|
|
|
@ -51,11 +51,8 @@ pub(crate) async fn get_login_types_route(
|
|||
///
|
||||
/// Note: You can use [`GET /_matrix/client/r0/login`](get_login_types_route) to
|
||||
/// see supported login types.
|
||||
#[allow(
|
||||
// To allow deprecated login methods
|
||||
deprecated,
|
||||
clippy::too_many_lines,
|
||||
)]
|
||||
#[expect(deprecated, reason = "To allow deprecated login methods")]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn login_route(
|
||||
body: Ar<login::v3::Request>,
|
||||
) -> Result<Ra<login::v3::Response>> {
|
||||
|
@ -252,8 +249,6 @@ pub(crate) async fn login_route(
|
|||
|
||||
info!(%user_id, %device_id, "User logged in");
|
||||
|
||||
// Homeservers are still required to send the `home_server` field
|
||||
#[allow(deprecated)]
|
||||
Ok(Ra(login::v3::Response {
|
||||
user_id,
|
||||
access_token: token,
|
||||
|
|
|
@ -36,8 +36,7 @@ use crate::{
|
|||
/// Synchronize the client's state with the latest state on the server.
|
||||
///
|
||||
/// - This endpoint takes a `since` parameter which should be the `next_batch`
|
||||
/// value from a
|
||||
/// previous request for incremental syncs.
|
||||
/// value from a previous request for incremental syncs.
|
||||
///
|
||||
/// Calling this endpoint without a `since` parameter returns:
|
||||
/// - Some of the most recent events of each timeline
|
||||
|
@ -50,11 +49,9 @@ use crate::{
|
|||
/// - Some of the most recent events of each timeline that happened after
|
||||
/// `since`
|
||||
/// - If user joined the room after `since`: All state events (unless lazy
|
||||
/// loading is activated) and
|
||||
/// all device list updates in that room
|
||||
/// loading is activated) and all device list updates in that room
|
||||
/// - If the user was already in the room: A list of all events that are in the
|
||||
/// state now, but were
|
||||
/// not in the state at `since`
|
||||
/// state now, but were not in the state at `since`
|
||||
/// - If the state we send contains a member event: Joined and invited member
|
||||
/// counts, heroes
|
||||
/// - Device list updates that happened after `since`
|
||||
|
@ -70,7 +67,7 @@ use crate::{
|
|||
/// For left rooms:
|
||||
/// - If the user left after `since`: `prev_batch` token, empty state (TODO:
|
||||
/// subset of the state at the point of the leave)
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn sync_events_route(
|
||||
body: Ar<sync_events::v3::Request>,
|
||||
) -> Result<Ra<sync_events::v3::Response>, Ra<UiaaResponse>> {
|
||||
|
@ -452,7 +449,7 @@ pub(crate) async fn sync_events_route(
|
|||
}
|
||||
|
||||
#[tracing::instrument(skip_all, fields(room_id = %room_id))]
|
||||
#[allow(clippy::too_many_arguments, clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_arguments)]
|
||||
async fn load_joined_room(
|
||||
sender_user: &UserId,
|
||||
sender_device: &DeviceId,
|
||||
|
@ -1124,7 +1121,7 @@ fn share_encrypted_room(
|
|||
.any(|encrypted| encrypted))
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn sync_events_v4_route(
|
||||
body: Ar<sync_events::v4::Request>,
|
||||
) -> Result<Ra<sync_events::v4::Response>, Ra<UiaaResponse>> {
|
||||
|
|
|
@ -13,8 +13,7 @@ use crate::{services, Ar, Ra, Result};
|
|||
/// Searches all known users for a match.
|
||||
///
|
||||
/// - Hides any local users that aren't in any public rooms (i.e. those that
|
||||
/// have the join rule set to public)
|
||||
/// and don't share a room with the sender
|
||||
/// have the join rule set to public) and don't share a room with the sender
|
||||
pub(crate) async fn search_users_route(
|
||||
body: Ar<search_users::v3::Request>,
|
||||
) -> Result<Ra<search_users::v3::Response>> {
|
||||
|
|
|
@ -50,7 +50,7 @@ struct ArPieces {
|
|||
|
||||
/// Non-generic part of [`Ar::from_request()`]. Splitting this out reduces
|
||||
/// binary size by ~10%.
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
async fn ar_from_request_inner(
|
||||
req: axum::extract::Request,
|
||||
metadata: Metadata,
|
||||
|
|
|
@ -347,7 +347,6 @@ fn add_port_to_hostname(destination_str: &str) -> FedDest {
|
|||
/// Implemented according to the specification at <https://matrix.org/docs/spec/server_server/r0.1.4#resolving-server-names>
|
||||
/// Numbers in comments below refer to bullet points in linked section of
|
||||
/// specification
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[tracing::instrument(ret(level = "debug"))]
|
||||
async fn find_actual_destination(
|
||||
destination: &'_ ServerName,
|
||||
|
@ -532,7 +531,7 @@ async fn request_well_known(destination: &str) -> Option<String> {
|
|||
let response = services()
|
||||
.globals
|
||||
.default_client()
|
||||
.get(&format!("https://{destination}/.well-known/matrix/server"))
|
||||
.get(format!("https://{destination}/.well-known/matrix/server"))
|
||||
.send()
|
||||
.await;
|
||||
debug!("Got well known response");
|
||||
|
@ -565,8 +564,7 @@ pub(crate) async fn get_server_version_route(
|
|||
/// Gets the public signing keys of this server.
|
||||
///
|
||||
/// - Matrix does not support invalidating public keys, so the key returned by
|
||||
/// this will be valid
|
||||
/// forever.
|
||||
/// this will be valid forever.
|
||||
// Response type for this endpoint is Json because we need to calculate a
|
||||
// signature for the response
|
||||
pub(crate) async fn get_server_keys_route() -> Result<impl IntoResponse> {
|
||||
|
@ -617,8 +615,7 @@ pub(crate) async fn get_server_keys_route() -> Result<impl IntoResponse> {
|
|||
/// Gets the public signing keys of this server.
|
||||
///
|
||||
/// - Matrix does not support invalidating public keys, so the key returned by
|
||||
/// this will be valid
|
||||
/// forever.
|
||||
/// this will be valid forever.
|
||||
pub(crate) async fn get_server_keys_deprecated_route() -> impl IntoResponse {
|
||||
get_server_keys_route().await
|
||||
}
|
||||
|
@ -704,7 +701,7 @@ pub(crate) fn parse_incoming_pdu(
|
|||
/// # `PUT /_matrix/federation/v1/send/{txnId}`
|
||||
///
|
||||
/// Push EDUs and PDUs to this server.
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn send_transaction_message_route(
|
||||
body: Ar<send_transaction_message::v1::Request>,
|
||||
) -> Result<Ra<send_transaction_message::v1::Response>> {
|
||||
|
@ -1536,7 +1533,7 @@ pub(crate) async fn create_join_event_template_route(
|
|||
}))
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
async fn create_join_event(
|
||||
sender_servername: &ServerName,
|
||||
room_id: &RoomId,
|
||||
|
@ -1681,7 +1678,7 @@ async fn create_join_event(
|
|||
/// # `PUT /_matrix/federation/v1/send_join/{roomId}/{eventId}`
|
||||
///
|
||||
/// Submits a signed join event.
|
||||
#[allow(deprecated)]
|
||||
#[expect(deprecated, reason = "support for deprecated API")]
|
||||
pub(crate) async fn create_join_event_v1_route(
|
||||
body: Ar<create_join_event::v1::Request>,
|
||||
) -> Result<Ra<create_join_event::v1::Response>> {
|
||||
|
@ -1725,7 +1722,7 @@ pub(crate) async fn create_join_event_v2_route(
|
|||
/// # `PUT /_matrix/federation/v2/invite/{roomId}/{eventId}`
|
||||
///
|
||||
/// Invites a remote user to a room.
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn create_invite_route(
|
||||
body: Ar<create_invite::v2::Request>,
|
||||
) -> Result<Ra<create_invite::v2::Response>> {
|
||||
|
|
|
@ -21,7 +21,7 @@ use proxy::ProxyConfig;
|
|||
pub(crate) static DEFAULT_PATH: Lazy<PathBuf> =
|
||||
Lazy::new(|| [env!("CARGO_PKG_NAME"), "config.toml"].iter().collect());
|
||||
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
#[expect(clippy::struct_excessive_bools, reason = "config schema struct")]
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(crate) struct Config {
|
||||
#[serde(default = "false_fn")]
|
||||
|
|
|
@ -91,13 +91,17 @@ pub(crate) struct KeyValueDatabase {
|
|||
pub(super) roomuserid_lastprivatereadupdate: Arc<dyn KvTree>,
|
||||
|
||||
// PresenceId = RoomId + Count + UserId
|
||||
// This exists in the database already but is currently unused
|
||||
#[allow(dead_code)]
|
||||
#[expect(
|
||||
dead_code,
|
||||
reason = "This exists in the database already but is currently unused"
|
||||
)]
|
||||
pub(super) presenceid_presence: Arc<dyn KvTree>,
|
||||
|
||||
// LastPresenceUpdate = Count
|
||||
// This exists in the database already but is currently unused
|
||||
#[allow(dead_code)]
|
||||
#[expect(
|
||||
dead_code,
|
||||
reason = "This exists in the database already but is currently unused"
|
||||
)]
|
||||
pub(super) userid_lastpresenceupdate: Arc<dyn KvTree>,
|
||||
|
||||
// Trees "owned" by `self::key_value::rooms`
|
||||
|
@ -311,7 +315,7 @@ impl KeyValueDatabase {
|
|||
not(any(feature = "rocksdb", feature = "sqlite")),
|
||||
allow(unreachable_code)
|
||||
)]
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn load_or_create(
|
||||
config: Config,
|
||||
reload_handles: FilterReloadHandles,
|
||||
|
@ -357,6 +361,14 @@ impl KeyValueDatabase {
|
|||
);
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation,
|
||||
reason = "saturating to usize is fine"
|
||||
)]
|
||||
let cache_capacity =
|
||||
(100_000.0 * config.cache_capacity_modifier) as usize;
|
||||
let db_raw = Box::new(Self {
|
||||
db: builder.clone(),
|
||||
userid_password: builder.open_tree("userid_password")?,
|
||||
|
@ -488,46 +500,11 @@ impl KeyValueDatabase {
|
|||
.try_into()
|
||||
.expect("pdu cache capacity fits into usize"),
|
||||
)),
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
auth_chain_cache: Mutex::new(LruCache::new(
|
||||
(100_000.0 * config.cache_capacity_modifier) as usize,
|
||||
)),
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
shorteventid_cache: Mutex::new(LruCache::new(
|
||||
(100_000.0 * config.cache_capacity_modifier) as usize,
|
||||
)),
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
eventidshort_cache: Mutex::new(LruCache::new(
|
||||
(100_000.0 * config.cache_capacity_modifier) as usize,
|
||||
)),
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
shortstatekey_cache: Mutex::new(LruCache::new(
|
||||
(100_000.0 * config.cache_capacity_modifier) as usize,
|
||||
)),
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
statekeyshort_cache: Mutex::new(LruCache::new(
|
||||
(100_000.0 * config.cache_capacity_modifier) as usize,
|
||||
)),
|
||||
auth_chain_cache: Mutex::new(LruCache::new(cache_capacity)),
|
||||
shorteventid_cache: Mutex::new(LruCache::new(cache_capacity)),
|
||||
eventidshort_cache: Mutex::new(LruCache::new(cache_capacity)),
|
||||
shortstatekey_cache: Mutex::new(LruCache::new(cache_capacity)),
|
||||
statekeyshort_cache: Mutex::new(LruCache::new(cache_capacity)),
|
||||
our_real_users_cache: RwLock::new(HashMap::new()),
|
||||
appservice_in_room_cache: RwLock::new(HashMap::new()),
|
||||
lasttimelinecount_cache: Mutex::new(HashMap::new()),
|
||||
|
|
|
@ -72,10 +72,11 @@ fn db_options(max_open_files: i32, rocksdb_cache: &Cache) -> Options {
|
|||
|
||||
impl KeyValueDatabaseEngine for Arc<Engine> {
|
||||
fn open(config: &Config) -> Result<Self> {
|
||||
#[allow(
|
||||
#[expect(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
clippy::cast_possible_truncation,
|
||||
reason = "saturating to usize is fine"
|
||||
)]
|
||||
let cache_capacity_bytes =
|
||||
(config.database.cache_capacity_mb * 1024.0 * 1024.0) as usize;
|
||||
|
@ -144,7 +145,11 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
|
|||
}))
|
||||
}
|
||||
|
||||
#[allow(clippy::as_conversions, clippy::cast_precision_loss)]
|
||||
#[expect(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_precision_loss,
|
||||
reason = "these are just informational"
|
||||
)]
|
||||
fn memory_usage(&self) -> Result<String> {
|
||||
let stats =
|
||||
get_memory_usage_stats(Some(&[&self.rocks]), Some(&[&self.cache]))?;
|
||||
|
|
|
@ -124,11 +124,12 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
|
|||
// 2. divide by permanent connections + permanent iter connections +
|
||||
// write connection
|
||||
// 3. round down to nearest integer
|
||||
#[allow(
|
||||
#[expect(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_possible_truncation,
|
||||
clippy::cast_precision_loss,
|
||||
clippy::cast_sign_loss
|
||||
clippy::cast_sign_loss,
|
||||
reason = "saturating to u32 is fine"
|
||||
)]
|
||||
let cache_size_per_thread =
|
||||
((config.database.cache_capacity_mb * 1024.0)
|
||||
|
|
|
@ -9,7 +9,10 @@ use tokio::sync::watch;
|
|||
|
||||
#[derive(Default)]
|
||||
pub(super) struct Watchers {
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(
|
||||
clippy::type_complexity,
|
||||
reason = "not actually all that complex"
|
||||
)]
|
||||
watchers:
|
||||
RwLock<HashMap<Vec<u8>, (watch::Sender<()>, watch::Receiver<()>)>>,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use std::mem;
|
||||
|
||||
use ruma::{
|
||||
events::receipt::ReceiptEvent, serde::Raw, CanonicalJsonObject,
|
||||
OwnedUserId, RoomId, UserId,
|
||||
|
@ -55,7 +53,7 @@ impl service::rooms::edus::read_receipt::Data for KeyValueDatabase {
|
|||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
fn readreceipts_since<'a>(
|
||||
&'a self,
|
||||
room_id: &RoomId,
|
||||
|
@ -83,7 +81,7 @@ impl service::rooms::edus::read_receipt::Data for KeyValueDatabase {
|
|||
.take_while(move |(k, _)| k.starts_with(&prefix2))
|
||||
.map(move |(k, v)| {
|
||||
let count = utils::u64_from_bytes(
|
||||
&k[prefix.len()..prefix.len() + mem::size_of::<u64>()],
|
||||
&k[prefix.len()..prefix.len() + size_of::<u64>()],
|
||||
)
|
||||
.map_err(|_| {
|
||||
Error::bad_database(
|
||||
|
@ -92,7 +90,7 @@ impl service::rooms::edus::read_receipt::Data for KeyValueDatabase {
|
|||
})?;
|
||||
let user_id = UserId::parse(
|
||||
utils::string_from_bytes(
|
||||
&k[prefix.len() + mem::size_of::<u64>() + 1..],
|
||||
&k[prefix.len() + size_of::<u64>() + 1..],
|
||||
)
|
||||
.map_err(|_| {
|
||||
Error::bad_database(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{mem, sync::Arc};
|
||||
use std::sync::Arc;
|
||||
|
||||
use ruma::{EventId, RoomId, UserId};
|
||||
|
||||
|
@ -41,11 +41,12 @@ impl service::rooms::pdu_metadata::Data for KeyValueDatabase {
|
|||
.iter_from(¤t, true)
|
||||
.take_while(move |(k, _)| k.starts_with(&prefix))
|
||||
.map(move |(tofrom, _data)| {
|
||||
let from = utils::u64_from_bytes(
|
||||
&tofrom[(mem::size_of::<u64>())..],
|
||||
)
|
||||
let from =
|
||||
utils::u64_from_bytes(&tofrom[(size_of::<u64>())..])
|
||||
.map_err(|_| {
|
||||
Error::bad_database("Invalid count in tofrom_relation.")
|
||||
Error::bad_database(
|
||||
"Invalid count in tofrom_relation.",
|
||||
)
|
||||
})?;
|
||||
|
||||
let mut pduid = shortroomid.to_be_bytes().to_vec();
|
||||
|
|
|
@ -57,7 +57,7 @@ impl service::rooms::search::Data for KeyValueDatabase {
|
|||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
fn search_pdus<'a>(
|
||||
&'a self,
|
||||
room_id: &RoomId,
|
||||
|
|
|
@ -482,7 +482,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
|
|||
}
|
||||
|
||||
/// Returns an iterator over all rooms a user was invited to.
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn rooms_invited<'a>(
|
||||
&'a self,
|
||||
|
@ -575,7 +575,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
|
|||
}
|
||||
|
||||
/// Returns an iterator over all rooms a user left.
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn rooms_left<'a>(
|
||||
&'a self,
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use std::mem;
|
||||
|
||||
use ruma::{
|
||||
api::client::threads::get_threads::v1::IncludeThreads, OwnedUserId, RoomId,
|
||||
UserId,
|
||||
|
@ -34,9 +32,8 @@ impl service::rooms::threads::Data for KeyValueDatabase {
|
|||
.iter_from(¤t, true)
|
||||
.take_while(move |(k, _)| k.starts_with(&prefix))
|
||||
.map(move |(pduid, _users)| {
|
||||
let count = utils::u64_from_bytes(
|
||||
&pduid[(mem::size_of::<u64>())..],
|
||||
)
|
||||
let count =
|
||||
utils::u64_from_bytes(&pduid[(size_of::<u64>())..])
|
||||
.map_err(|_| {
|
||||
Error::bad_database(
|
||||
"Invalid pduid in threadid_userids.",
|
||||
|
|
15
src/error.rs
15
src/error.rs
|
@ -35,9 +35,6 @@ impl fmt::Display for DisplayWithSources<'_> {
|
|||
}
|
||||
|
||||
/// Top-level errors
|
||||
// Missing docs are allowed here since that kind of information should be
|
||||
// encoded in the error messages themselves anyway.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Error, Debug)]
|
||||
pub(crate) enum Main {
|
||||
#[error("failed to load configuration")]
|
||||
|
@ -54,9 +51,6 @@ pub(crate) enum Main {
|
|||
}
|
||||
|
||||
/// Observability initialization errors
|
||||
// Missing docs are allowed here since that kind of information should be
|
||||
// encoded in the error messages themselves anyway.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Error, Debug)]
|
||||
pub(crate) enum Observability {
|
||||
// Upstream's documentation on what this error means is very sparse
|
||||
|
@ -72,9 +66,6 @@ pub(crate) enum Observability {
|
|||
}
|
||||
|
||||
/// Configuration errors
|
||||
// Missing docs are allowed here since that kind of information should be
|
||||
// encoded in the error messages themselves anyway.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Error, Debug)]
|
||||
pub(crate) enum Config {
|
||||
#[error("failed to find configuration file")]
|
||||
|
@ -88,9 +79,6 @@ pub(crate) enum Config {
|
|||
}
|
||||
|
||||
/// Errors that can occur while searching for a config file
|
||||
// Missing docs are allowed here since that kind of information should be
|
||||
// encoded in the error messages themselves anyway.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Error, Debug)]
|
||||
pub(crate) enum ConfigSearch {
|
||||
#[error("XDG Base Directory error")]
|
||||
|
@ -101,9 +89,6 @@ pub(crate) enum ConfigSearch {
|
|||
}
|
||||
|
||||
/// Errors serving traffic
|
||||
// Missing docs are allowed here since that kind of information should be
|
||||
// encoded in the error messages themselves anyway.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Error, Debug)]
|
||||
pub(crate) enum Serve {
|
||||
#[error("no listeners were specified in the configuration file")]
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -136,7 +136,7 @@ async fn try_main() -> Result<(), error::Main> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
async fn run_server() -> Result<(), error::Serve> {
|
||||
use error::Serve as Error;
|
||||
|
||||
|
@ -296,7 +296,7 @@ async fn unrecognized_method(
|
|||
Ok(inner)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines, reason = "there's a lot of routes")]
|
||||
fn routes(config: &Config) -> Router {
|
||||
use client_server as c2s;
|
||||
use server_server as s2s;
|
||||
|
@ -593,7 +593,6 @@ pub(crate) trait RumaHandler<T> {
|
|||
macro_rules! impl_ruma_handler {
|
||||
( $($ty:ident),* $(,)? ) => {
|
||||
#[axum::async_trait]
|
||||
#[allow(non_snake_case)]
|
||||
impl<Req, Resp, E, F, Fut, $($ty,)*>
|
||||
RumaHandler<($($ty,)* Ar<Req>,)> for F
|
||||
where
|
||||
|
@ -616,7 +615,10 @@ macro_rules! impl_ruma_handler {
|
|||
path,
|
||||
on(
|
||||
method_filter,
|
||||
|$( $ty: $ty, )* req: Ar<Req>| async move {
|
||||
|$(#[expect(
|
||||
non_snake_case,
|
||||
reason = "reuse of macro fragments",
|
||||
)] $ty: $ty,)* req: Ar<Req>| async move {
|
||||
let span = info_span!(
|
||||
"run_ruma_handler",
|
||||
auth.user = ?req.sender_user,
|
||||
|
|
|
@ -38,7 +38,7 @@ pub(crate) static METRICS: Lazy<Metrics> = Lazy::new(Metrics::new);
|
|||
/// Cleans up resources relating to observability when [`Drop`]ped
|
||||
pub(crate) struct Guard {
|
||||
/// Drop guard used to flush [`tracing_flame`] data on exit
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code, reason = "only exists to be dropped")]
|
||||
flame_guard: Option<FlushGuard<BufWriter<File>>>,
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,10 @@ pub(crate) type FilterReloadHandle = Box<dyn ReloadHandle<EnvFilter> + Sync>;
|
|||
/// Collection of [`FilterReloadHandle`]s, allowing the filters for tracing
|
||||
/// backends to be changed dynamically. Handles may be [`None`] if the backend
|
||||
/// is disabled in the config.
|
||||
#[allow(clippy::missing_docs_in_private_items)]
|
||||
#[expect(
|
||||
clippy::missing_docs_in_private_items,
|
||||
reason = "mirrors config struct layout"
|
||||
)]
|
||||
pub(crate) struct FilterReloadHandles {
|
||||
pub(crate) traces: Option<FilterReloadHandle>,
|
||||
pub(crate) flame: Option<FilterReloadHandle>,
|
||||
|
@ -90,7 +93,7 @@ pub(crate) struct FilterReloadHandles {
|
|||
///
|
||||
/// See also [`Metrics::record_lookup`].
|
||||
// Keep variants sorted
|
||||
#[allow(clippy::missing_docs_in_private_items)]
|
||||
#[expect(clippy::missing_docs_in_private_items)]
|
||||
#[derive(Clone, Copy, AsRefStr, IntoStaticStr)]
|
||||
pub(crate) enum Lookup {
|
||||
AppserviceInRoom,
|
||||
|
@ -196,7 +199,7 @@ pub(crate) fn init(
|
|||
let (log_layer, log_filter, _) =
|
||||
make_backend(true, &config.observability.logs.filter, || {
|
||||
/// Time format selection for `tracing_subscriber` at runtime
|
||||
#[allow(clippy::missing_docs_in_private_items)]
|
||||
#[expect(clippy::missing_docs_in_private_items, reason = "trivial")]
|
||||
enum TimeFormat {
|
||||
SystemTime,
|
||||
NoTime,
|
||||
|
|
|
@ -56,6 +56,14 @@ impl Services {
|
|||
config: Config,
|
||||
reload_handles: FilterReloadHandles,
|
||||
) -> Result<Self> {
|
||||
#[expect(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation,
|
||||
reason = "usize is an acceptable range to saturate to"
|
||||
)]
|
||||
let cache_capacity = (100.0 * config.cache_capacity_modifier) as usize;
|
||||
|
||||
Ok(Self {
|
||||
appservice: appservice::Service::build(db)?,
|
||||
pusher: pusher::Service {
|
||||
|
@ -92,21 +100,11 @@ impl Services {
|
|||
},
|
||||
state_accessor: rooms::state_accessor::Service {
|
||||
db,
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
server_visibility_cache: StdMutex::new(LruCache::new(
|
||||
(100.0 * config.cache_capacity_modifier) as usize,
|
||||
cache_capacity,
|
||||
)),
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
user_visibility_cache: StdMutex::new(LruCache::new(
|
||||
(100.0 * config.cache_capacity_modifier) as usize,
|
||||
cache_capacity,
|
||||
)),
|
||||
},
|
||||
state_cache: rooms::state_cache::Service {
|
||||
|
@ -114,13 +112,8 @@ impl Services {
|
|||
},
|
||||
state_compressor: rooms::state_compressor::Service {
|
||||
db,
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
stateinfo_cache: StdMutex::new(LruCache::new(
|
||||
(100.0 * config.cache_capacity_modifier) as usize,
|
||||
cache_capacity,
|
||||
)),
|
||||
},
|
||||
timeline: rooms::timeline::Service {
|
||||
|
|
|
@ -55,8 +55,10 @@ enum AdminCommand {
|
|||
/// # ```
|
||||
/// # yaml content here
|
||||
/// # ```
|
||||
// Allowed because the doc comment gets parsed by our code later
|
||||
#[allow(clippy::doc_markdown)]
|
||||
#[expect(
|
||||
clippy::doc_markdown,
|
||||
reason = "the doc comment gets parsed by our code later"
|
||||
)]
|
||||
RegisterAppservice,
|
||||
|
||||
/// Unregister an appservice using its ID
|
||||
|
@ -104,8 +106,10 @@ enum AdminCommand {
|
|||
/// # ```
|
||||
/// # User list here
|
||||
/// # ```
|
||||
// Allowed because the doc comment gets parsed by our code later
|
||||
#[allow(clippy::doc_markdown)]
|
||||
#[expect(
|
||||
clippy::doc_markdown,
|
||||
reason = "the doc comment gets parsed by our code later"
|
||||
)]
|
||||
DeactivateAll {
|
||||
#[arg(short, long)]
|
||||
/// Remove users from their joined rooms
|
||||
|
@ -131,8 +135,10 @@ enum AdminCommand {
|
|||
/// # ```
|
||||
/// # PDU json content here
|
||||
/// # ```
|
||||
// Allowed because the doc comment gets parsed by our code later
|
||||
#[allow(clippy::doc_markdown)]
|
||||
#[expect(
|
||||
clippy::doc_markdown,
|
||||
reason = "the doc comment gets parsed by our code later"
|
||||
)]
|
||||
ParsePdu,
|
||||
|
||||
/// Retrieve and print a PDU by ID from the Grapevine database
|
||||
|
@ -184,8 +190,10 @@ enum AdminCommand {
|
|||
/// # ```
|
||||
/// # json here
|
||||
/// # ```
|
||||
// Allowed because the doc comment gets parsed by our code later
|
||||
#[allow(clippy::doc_markdown)]
|
||||
#[expect(
|
||||
clippy::doc_markdown,
|
||||
reason = "the doc comment gets parsed by our code later"
|
||||
)]
|
||||
SignJson,
|
||||
|
||||
/// Verify json signatures
|
||||
|
@ -193,8 +201,10 @@ enum AdminCommand {
|
|||
/// # ```
|
||||
/// # json here
|
||||
/// # ```
|
||||
// Allowed because the doc comment gets parsed by our code later
|
||||
#[allow(clippy::doc_markdown)]
|
||||
#[expect(
|
||||
clippy::doc_markdown,
|
||||
reason = "the doc comment gets parsed by our code later"
|
||||
)]
|
||||
VerifyJson,
|
||||
|
||||
/// Dynamically change a tracing backend's filter string
|
||||
|
@ -389,7 +399,6 @@ impl Service {
|
|||
AdminCommand::try_parse_from(argv).map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[tracing::instrument(skip(self, body))]
|
||||
async fn process_admin_command(
|
||||
&self,
|
||||
|
@ -1205,7 +1214,6 @@ impl Service {
|
|||
/// Users in this room are considered admins by grapevine, and the room can
|
||||
/// be used to issue admin commands by talking to the server user inside
|
||||
/// it.
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub(crate) async fn create_admin_room(&self) -> Result<()> {
|
||||
let room_id = RoomId::new(services().globals.server_name());
|
||||
|
@ -1452,7 +1460,7 @@ impl Service {
|
|||
/// Errors are propagated from the database, and will have None if there is
|
||||
/// no admin room
|
||||
// Allowed because this function uses `services()`
|
||||
#[allow(clippy::unused_self)]
|
||||
#[expect(clippy::unused_self)]
|
||||
pub(crate) fn get_admin_room(&self) -> Result<Option<OwnedRoomId>> {
|
||||
services()
|
||||
.rooms
|
||||
|
|
|
@ -102,7 +102,7 @@ pub(crate) struct RotationHandler(
|
|||
// TODO: Determine if it's safe to delete this field. I'm not deleting it
|
||||
// right now because I'm unsure what implications that would have for how
|
||||
// the sender expects to work.
|
||||
#[allow(dead_code)] broadcast::Receiver<()>,
|
||||
#[expect(dead_code, reason = "see comment")] broadcast::Receiver<()>,
|
||||
);
|
||||
|
||||
impl RotationHandler {
|
||||
|
@ -443,7 +443,7 @@ impl Service {
|
|||
/// Filters the key map of multiple servers down to keys that should be
|
||||
/// accepted given the expiry time, room version, and timestamp of the
|
||||
/// paramters
|
||||
#[allow(clippy::unused_self)]
|
||||
#[expect(clippy::unused_self, reason = "exposed via services()")]
|
||||
pub(crate) fn filter_keys_server_map(
|
||||
&self,
|
||||
keys: BTreeMap<String, SigningKeys>,
|
||||
|
@ -452,7 +452,11 @@ impl Service {
|
|||
) -> BTreeMap<String, BTreeMap<String, Base64>> {
|
||||
keys.into_iter()
|
||||
.filter_map(|(server, keys)| {
|
||||
self.filter_keys_single_server(keys, timestamp, room_version_id)
|
||||
Self::filter_keys_single_server(
|
||||
keys,
|
||||
timestamp,
|
||||
room_version_id,
|
||||
)
|
||||
.map(|keys| (server, keys))
|
||||
})
|
||||
.collect()
|
||||
|
@ -460,9 +464,7 @@ impl Service {
|
|||
|
||||
/// Filters the keys of a single server down to keys that should be accepted
|
||||
/// given the expiry time, room version, and timestamp of the paramters
|
||||
#[allow(clippy::unused_self)]
|
||||
pub(crate) fn filter_keys_single_server(
|
||||
&self,
|
||||
keys: SigningKeys,
|
||||
timestamp: MilliSecondsSinceUnixEpoch,
|
||||
_room_version_id: &RoomVersionId,
|
||||
|
|
|
@ -19,7 +19,6 @@ pub(crate) struct FileMeta {
|
|||
//
|
||||
// TODO: Write a database migration to get rid of this and instead store
|
||||
// only the filename instead of the entire `Content-Disposition` header.
|
||||
#[allow(dead_code)]
|
||||
pub(crate) content_disposition: Option<String>,
|
||||
pub(crate) content_type: Option<String>,
|
||||
}
|
||||
|
@ -171,23 +170,23 @@ impl Service {
|
|||
/ u64::from(original_height)
|
||||
};
|
||||
if use_width {
|
||||
if intermediate <= u64::from(::std::u32::MAX) {
|
||||
(width, intermediate.try_into().unwrap_or(u32::MAX))
|
||||
if let Ok(intermediate) = u32::try_from(intermediate) {
|
||||
(width, intermediate)
|
||||
} else {
|
||||
(
|
||||
(u64::from(width) * u64::from(::std::u32::MAX)
|
||||
(u64::from(width) * u64::from(u32::MAX)
|
||||
/ intermediate)
|
||||
.try_into()
|
||||
.unwrap_or(u32::MAX),
|
||||
::std::u32::MAX,
|
||||
u32::MAX,
|
||||
)
|
||||
}
|
||||
} else if intermediate <= u64::from(::std::u32::MAX) {
|
||||
(intermediate.try_into().unwrap_or(u32::MAX), height)
|
||||
} else if let Ok(intermediate) = u32::try_from(intermediate) {
|
||||
(intermediate, height)
|
||||
} else {
|
||||
(
|
||||
::std::u32::MAX,
|
||||
(u64::from(height) * u64::from(::std::u32::MAX)
|
||||
u32::MAX,
|
||||
(u64::from(height) * u64::from(u32::MAX)
|
||||
/ intermediate)
|
||||
.try_into()
|
||||
.unwrap_or(u32::MAX),
|
||||
|
|
|
@ -48,9 +48,12 @@ impl Service {
|
|||
for id in starting_events {
|
||||
let short =
|
||||
services().rooms.short.get_or_create_shorteventid(&id)?;
|
||||
// I'm afraid to change this in case there is accidental reliance on
|
||||
// the truncation
|
||||
#[allow(clippy::as_conversions, clippy::cast_possible_truncation)]
|
||||
#[expect(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_possible_truncation,
|
||||
reason = "I'm afraid to change this in case there is accidental
|
||||
reliance on the truncation"
|
||||
)]
|
||||
let bucket_id = (short % NUM_BUCKETS as u64) as usize;
|
||||
buckets[bucket_id].insert((short, id.clone()));
|
||||
i += 1;
|
||||
|
|
|
@ -15,7 +15,7 @@ pub(crate) trait Data: Send + Sync {
|
|||
|
||||
/// Returns an iterator over the most recent read receipts in a room that
|
||||
/// happened after the event with id `since`.
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
fn readreceipts_since<'a>(
|
||||
&'a self,
|
||||
room_id: &RoomId,
|
||||
|
@ -40,7 +40,7 @@ pub(crate) trait Data: Send + Sync {
|
|||
|
||||
/// Returns the private read marker.
|
||||
// TODO: Implement MSC2285
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code, reason = "private read receipts are unimplemented")]
|
||||
fn private_read_get(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
|
@ -49,7 +49,7 @@ pub(crate) trait Data: Send + Sync {
|
|||
|
||||
/// Returns the count of the last typing update in this room.
|
||||
// TODO: Implement MSC2285
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code, reason = "private read receipts are unimplemented")]
|
||||
fn last_privateread_update(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
|
|
|
@ -309,7 +309,7 @@ impl Service {
|
|||
r
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[expect(clippy::too_many_arguments)]
|
||||
#[tracing::instrument(skip(self, origin, room_id, value, pub_key_map))]
|
||||
fn handle_outlier_pdu<'a>(
|
||||
&'a self,
|
||||
|
@ -1436,7 +1436,7 @@ impl Service {
|
|||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
async fn fetch_unknown_prev_events(
|
||||
&self,
|
||||
origin: &ServerName,
|
||||
|
@ -1712,7 +1712,7 @@ impl Service {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) async fn fetch_join_signing_keys(
|
||||
&self,
|
||||
event: &create_join_event::v2::Response,
|
||||
|
@ -1843,8 +1843,6 @@ impl Service {
|
|||
}
|
||||
|
||||
/// Returns Ok if the acl allows the server
|
||||
// Allowed because this function uses `services()`
|
||||
#[allow(clippy::unused_self)]
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub(crate) fn acl_check(
|
||||
&self,
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::Result;
|
|||
pub(crate) struct Service {
|
||||
pub(crate) db: &'static dyn Data,
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
pub(crate) lazy_load_waiting: Mutex<
|
||||
HashMap<
|
||||
(OwnedUserId, OwnedDeviceId, OwnedRoomId, PduCount),
|
||||
|
|
|
@ -45,7 +45,7 @@ impl Service {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments, clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_arguments)]
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub(crate) fn paginate_relations_with_filter(
|
||||
&self,
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::{service::rooms::timeline::PduCount, PduEvent, Result};
|
|||
|
||||
pub(crate) trait Data: Send + Sync {
|
||||
fn add_relation(&self, from: u64, to: u64) -> Result<()>;
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
fn relations_until<'a>(
|
||||
&'a self,
|
||||
user_id: &'a UserId,
|
||||
|
|
|
@ -17,7 +17,7 @@ pub(crate) trait Data: Send + Sync {
|
|||
message_body: &str,
|
||||
) -> Result<()>;
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
fn search_pdus<'a>(
|
||||
&'a self,
|
||||
room_id: &RoomId,
|
||||
|
|
|
@ -50,7 +50,6 @@ pub(crate) struct Service {
|
|||
}
|
||||
|
||||
impl Service {
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub(crate) async fn get_hierarchy(
|
||||
&self,
|
||||
|
@ -326,7 +325,6 @@ impl Service {
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[tracing::instrument(skip(self, children))]
|
||||
fn get_room_chunk(
|
||||
&self,
|
||||
|
@ -532,8 +530,7 @@ impl Service {
|
|||
}
|
||||
}
|
||||
|
||||
// Allowed because this function uses `services()`
|
||||
#[allow(clippy::unused_self)]
|
||||
#[expect(clippy::unused_self, reason = "uses services()")]
|
||||
fn handle_simplified_join_rule(
|
||||
&self,
|
||||
join_rule: &SpaceRoomJoinRule,
|
||||
|
|
|
@ -386,8 +386,6 @@ impl Service {
|
|||
)
|
||||
}
|
||||
|
||||
// Allowed because this function uses `services()`
|
||||
#[allow(clippy::unused_self)]
|
||||
#[tracing::instrument(skip(self), ret(level = "trace"))]
|
||||
pub(crate) fn user_can_invite(
|
||||
&self,
|
||||
|
|
|
@ -175,8 +175,7 @@ impl Service {
|
|||
}
|
||||
|
||||
/// Copy `m.tag` account data to an upgraded room.
|
||||
// Allowed because this function uses `services()`
|
||||
#[allow(clippy::unused_self)]
|
||||
#[expect(clippy::unused_self, reason = "uses services()")]
|
||||
fn copy_upgraded_account_data_tag(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
|
@ -206,8 +205,7 @@ impl Service {
|
|||
}
|
||||
|
||||
/// Copy references in `m.direct` account data events to an upgraded room.
|
||||
// Allowed because this function uses `services()`
|
||||
#[allow(clippy::unused_self)]
|
||||
#[expect(clippy::unused_self, reason = "uses services()")]
|
||||
fn copy_upgraded_account_data_direct(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
|
|
|
@ -93,7 +93,7 @@ pub(crate) trait Data: Send + Sync {
|
|||
) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a>;
|
||||
|
||||
/// Returns an iterator over all rooms a user was invited to.
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
fn rooms_invited<'a>(
|
||||
&'a self,
|
||||
user_id: &UserId,
|
||||
|
@ -116,7 +116,7 @@ pub(crate) trait Data: Send + Sync {
|
|||
) -> Result<Option<Vec<Raw<AnyStrippedStateEvent>>>>;
|
||||
|
||||
/// Returns an iterator over all rooms a user left.
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
fn rooms_left<'a>(
|
||||
&'a self,
|
||||
user_id: &UserId,
|
||||
|
@ -132,6 +132,6 @@ pub(crate) trait Data: Send + Sync {
|
|||
fn is_invited(&self, user_id: &UserId, room_id: &RoomId) -> Result<bool>;
|
||||
|
||||
// TODO: Use this when implementing sync filtering
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code, reason = "sync filtering is unimplemented")]
|
||||
fn is_left(&self, user_id: &UserId, room_id: &RoomId) -> Result<bool>;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ pub(crate) struct CompressedStateLayer {
|
|||
pub(crate) struct Service {
|
||||
pub(crate) db: &'static dyn Data,
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub(crate) stateinfo_cache: Mutex<LruCache<u64, Vec<CompressedStateLayer>>>,
|
||||
}
|
||||
|
||||
|
@ -37,7 +36,6 @@ pub(crate) type CompressedStateEvent = [u8; 2 * size_of::<u64>()];
|
|||
impl Service {
|
||||
/// Returns a stack with info on shortstatehash, full state, added diff and
|
||||
/// removed diff for the selected shortstatehash and each parent layer.
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub(crate) fn load_shortstatehash_info(
|
||||
&self,
|
||||
|
@ -92,8 +90,7 @@ impl Service {
|
|||
Ok(response)
|
||||
}
|
||||
|
||||
// Allowed because this function uses `services()`
|
||||
#[allow(clippy::unused_self)]
|
||||
#[expect(clippy::unused_self, reason = "uses services()")]
|
||||
pub(crate) fn compress_state_event(
|
||||
&self,
|
||||
shortstatekey: u64,
|
||||
|
@ -111,8 +108,7 @@ impl Service {
|
|||
}
|
||||
|
||||
/// Returns shortstatekey, event id
|
||||
// Allowed because this function uses `services()`
|
||||
#[allow(clippy::unused_self)]
|
||||
#[expect(clippy::unused_self, reason = "uses services()")]
|
||||
pub(crate) fn parse_compressed_state_event(
|
||||
&self,
|
||||
compressed_event: &CompressedStateEvent,
|
||||
|
@ -145,7 +141,6 @@ impl Service {
|
|||
/// for this layer
|
||||
/// * `parent_states` - A stack with info on shortstatehash, full state,
|
||||
/// added diff and removed diff for each parent layer
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[tracing::instrument(skip(
|
||||
self,
|
||||
statediffnew,
|
||||
|
@ -268,7 +263,7 @@ impl Service {
|
|||
|
||||
/// Returns the new shortstatehash, and the state diff from the previous
|
||||
/// room state
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
#[tracing::instrument(skip(self, new_state_ids_compressed))]
|
||||
pub(crate) fn save_state(
|
||||
&self,
|
||||
|
|
|
@ -6,7 +6,7 @@ use ruma::{
|
|||
use crate::{PduEvent, Result};
|
||||
|
||||
pub(crate) trait Data: Send + Sync {
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
fn threads_until<'a>(
|
||||
&'a self,
|
||||
user_id: &'a UserId,
|
||||
|
|
|
@ -678,7 +678,7 @@ impl Service {
|
|||
Ok(pdu_id)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) fn create_hash_and_sign_event(
|
||||
&self,
|
||||
pdu_builder: PduBuilder,
|
||||
|
|
|
@ -82,7 +82,7 @@ pub(crate) trait Data: Send + Sync {
|
|||
/// Returns an iterator over all events and their tokens in a room that
|
||||
/// happened before the event with id `until` in reverse-chronological
|
||||
/// order.
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
fn pdus_until<'a>(
|
||||
&'a self,
|
||||
user_id: &UserId,
|
||||
|
@ -92,7 +92,7 @@ pub(crate) trait Data: Send + Sync {
|
|||
|
||||
/// Returns an iterator over all events in a room that happened after the
|
||||
/// event with id `from` in chronological order.
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[expect(clippy::type_complexity)]
|
||||
fn pdus_after<'a>(
|
||||
&'a self,
|
||||
user_id: &UserId,
|
||||
|
|
|
@ -4,7 +4,6 @@ use super::{Destination, RequestKey, SendingEventType};
|
|||
use crate::Result;
|
||||
|
||||
pub(crate) trait Data: Send + Sync {
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn active_requests<'a>(
|
||||
&'a self,
|
||||
) -> Box<
|
||||
|
|
|
@ -32,15 +32,12 @@ pub(crate) struct SlidingSyncCache {
|
|||
extensions: ExtensionsConfig,
|
||||
}
|
||||
|
||||
type ConnectionKey = (OwnedUserId, OwnedDeviceId, String);
|
||||
|
||||
pub(crate) struct Service {
|
||||
pub(crate) db: &'static dyn Data,
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub(crate) connections: Mutex<
|
||||
BTreeMap<
|
||||
(OwnedUserId, OwnedDeviceId, String),
|
||||
Arc<Mutex<SlidingSyncCache>>,
|
||||
>,
|
||||
>,
|
||||
pub(crate) connections:
|
||||
Mutex<BTreeMap<ConnectionKey, Arc<Mutex<SlidingSyncCache>>>>,
|
||||
}
|
||||
|
||||
impl Service {
|
||||
|
@ -58,7 +55,7 @@ impl Service {
|
|||
self.connections.lock().unwrap().remove(&(user_id, device_id, conn_id));
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[expect(clippy::too_many_lines)]
|
||||
pub(crate) fn update_sync_request_with_cache(
|
||||
&self,
|
||||
user_id: OwnedUserId,
|
||||
|
@ -255,8 +252,10 @@ impl Service {
|
|||
}
|
||||
|
||||
/// Check if a user is an admin
|
||||
// Allowed because this function uses `services()`
|
||||
#[allow(clippy::unused_self)]
|
||||
#[expect(
|
||||
clippy::unused_self,
|
||||
reason = "Allowed because this function uses `services()`"
|
||||
)]
|
||||
pub(crate) fn is_admin(&self, user_id: &UserId) -> Result<bool> {
|
||||
services().admin.get_admin_room()?.map_or(Ok(false), |admin_room_id| {
|
||||
services().rooms.state_cache.is_joined(user_id, &admin_room_id)
|
||||
|
|
12
src/utils.rs
12
src/utils.rs
|
@ -19,8 +19,11 @@ use ruma::{
|
|||
|
||||
use crate::{Error, Result};
|
||||
|
||||
// Hopefully we have a better chat protocol in 530 years
|
||||
#[allow(clippy::as_conversions, clippy::cast_possible_truncation)]
|
||||
#[expect(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_possible_truncation,
|
||||
reason = "Hopefully we have a better chat protocol in 530 years"
|
||||
)]
|
||||
pub(crate) fn millis_since_unix_epoch() -> u64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
|
@ -241,7 +244,10 @@ pub(crate) fn dbg_truncate_str(s: &str, mut max_len: usize) -> Cow<'_, str> {
|
|||
if s.len() <= max_len {
|
||||
s.into()
|
||||
} else {
|
||||
#[allow(clippy::string_slice)] // we checked it's at a char boundary
|
||||
#[expect(
|
||||
clippy::string_slice,
|
||||
reason = "we checked it's at a char boundary"
|
||||
)]
|
||||
format!("{}...", &s[..max_len]).into()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,10 @@ use crate::Ra;
|
|||
pub(crate) type Result<T, E = Error> = std::result::Result<T, E>;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[allow(clippy::error_impl_error)]
|
||||
#[expect(
|
||||
clippy::error_impl_error,
|
||||
reason = "This is our one and only Error struct"
|
||||
)]
|
||||
pub(crate) enum Error {
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[error(
|
||||
|
|
Loading…
Reference in a new issue