mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
Use #[expect], lint reasons
This commit is contained in:
parent
e14b7f28f2
commit
b09c44a0ca
49 changed files with 157 additions and 161 deletions
|
|
@ -19,6 +19,8 @@ unused_qualifications = "warn"
|
||||||
pedantic = { level = "warn", priority = -1 }
|
pedantic = { level = "warn", priority = -1 }
|
||||||
|
|
||||||
# Lints. Keep alphabetically sorted
|
# Lints. Keep alphabetically sorted
|
||||||
|
allow_attributes = "warn"
|
||||||
|
allow_attributes_without_reason = "warn"
|
||||||
as_conversions = "warn"
|
as_conversions = "warn"
|
||||||
assertions_on_result_states = "warn"
|
assertions_on_result_states = "warn"
|
||||||
dbg_macro = "warn"
|
dbg_macro = "warn"
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ pub(crate) async fn get_register_available_route(
|
||||||
/// - Creates a new account and populates it with default account data
|
/// - Creates a new account and populates it with default account data
|
||||||
/// - If `inhibit_login` is false: Creates a device and returns `device_id` and
|
/// - If `inhibit_login` is false: Creates a device and returns `device_id` and
|
||||||
/// `access_token`
|
/// `access_token`
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
pub(crate) async fn register_route(
|
pub(crate) async fn register_route(
|
||||||
body: Ar<register::v3::Request>,
|
body: Ar<register::v3::Request>,
|
||||||
) -> Result<Ra<register::v3::Response>> {
|
) -> Result<Ra<register::v3::Response>> {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ use crate::{services, Ar, Error, Ra, Result};
|
||||||
///
|
///
|
||||||
/// - Only works if the user is joined (TODO: always allow, but only show events
|
/// - Only works if the user is joined (TODO: always allow, but only show events
|
||||||
/// if the user was joined, depending on `history_visibility`)
|
/// if the user was joined, depending on `history_visibility`)
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
pub(crate) async fn get_context_route(
|
pub(crate) async fn get_context_route(
|
||||||
body: Ar<get_context::v3::Request>,
|
body: Ar<get_context::v3::Request>,
|
||||||
) -> Result<Ra<get_context::v3::Response>> {
|
) -> 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(
|
pub(crate) async fn get_public_rooms_filtered_helper(
|
||||||
server: Option<&ServerName>,
|
server: Option<&ServerName>,
|
||||||
limit: Option<UInt>,
|
limit: Option<UInt>,
|
||||||
|
|
@ -267,7 +267,6 @@ pub(crate) async fn get_public_rooms_filtered_helper(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
fn room_id_to_chunk(room_id: ruma::OwnedRoomId) -> Result<PublicRoomsChunk> {
|
fn room_id_to_chunk(room_id: ruma::OwnedRoomId) -> Result<PublicRoomsChunk> {
|
||||||
let canonical_alias = services()
|
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>(
|
pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
|
||||||
sender_user: Option<&UserId>,
|
sender_user: Option<&UserId>,
|
||||||
device_keys_input: &BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>,
|
device_keys_input: &BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>,
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ fn set_header_or_panic(
|
||||||
/// # `GET /_matrix/media/r0/config`
|
/// # `GET /_matrix/media/r0/config`
|
||||||
///
|
///
|
||||||
/// Returns max upload size.
|
/// Returns max upload size.
|
||||||
#[allow(deprecated)] // unauthenticated media
|
#[expect(deprecated, reason = "legacy media APIs")]
|
||||||
pub(crate) async fn get_media_config_legacy_route(
|
pub(crate) async fn get_media_config_legacy_route(
|
||||||
_body: Ar<legacy_media::get_media_config::v3::Request>,
|
_body: Ar<legacy_media::get_media_config::v3::Request>,
|
||||||
) -> Result<Ra<legacy_media::get_media_config::v3::Response>> {
|
) -> Result<Ra<legacy_media::get_media_config::v3::Response>> {
|
||||||
|
|
@ -196,7 +196,7 @@ impl From<bool> for AllowRemote {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RemoteResponse {
|
struct RemoteResponse {
|
||||||
#[allow(unused)]
|
#[expect(unused, reason = "placeholder for future spec changes")]
|
||||||
metadata: authenticated_media_fed::ContentMetadata,
|
metadata: authenticated_media_fed::ContentMetadata,
|
||||||
content: authenticated_media_fed::Content,
|
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)]
|
#[tracing::instrument(skip_all)]
|
||||||
async fn get_remote_content_via_legacy_api(
|
async fn get_remote_content_via_legacy_api(
|
||||||
mxc: &MxcData<'_>,
|
mxc: &MxcData<'_>,
|
||||||
|
|
@ -365,7 +365,7 @@ pub(crate) async fn get_remote_content(
|
||||||
/// Load media from our server or over federation.
|
/// Load media from our server or over federation.
|
||||||
///
|
///
|
||||||
/// - Only allows federation if `allow_remote` is true
|
/// - 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(
|
pub(crate) async fn get_content_legacy_route(
|
||||||
body: Ar<legacy_media::get_content::v3::Request>,
|
body: Ar<legacy_media::get_content::v3::Request>,
|
||||||
) -> Result<axum::response::Response> {
|
) -> 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.
|
/// Load media from our server or over federation, permitting desired filename.
|
||||||
///
|
///
|
||||||
/// - Only allows federation if `allow_remote` is true
|
/// - 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(
|
pub(crate) async fn get_content_as_filename_legacy_route(
|
||||||
body: Ar<legacy_media::get_content_as_filename::v3::Request>,
|
body: Ar<legacy_media::get_content_as_filename::v3::Request>,
|
||||||
) -> Result<axum::response::Response> {
|
) -> 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.
|
/// Load media thumbnail from our server or over federation.
|
||||||
///
|
///
|
||||||
/// - Only allows federation if `allow_remote` is true
|
/// - 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(
|
pub(crate) async fn get_content_thumbnail_legacy_route(
|
||||||
body: Ar<legacy_media::get_content_thumbnail::v3::Request>,
|
body: Ar<legacy_media::get_content_thumbnail::v3::Request>,
|
||||||
) -> Result<axum::response::Response> {
|
) -> 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)]
|
#[tracing::instrument(skip_all)]
|
||||||
async fn get_remote_thumbnail_via_legacy_api(
|
async fn get_remote_thumbnail_via_legacy_api(
|
||||||
server_name: &ruma::ServerName,
|
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))]
|
#[tracing::instrument(skip(reason, _third_party_signed))]
|
||||||
async fn join_room_by_id_helper(
|
async fn join_room_by_id_helper(
|
||||||
sender_user: Option<&UserId>,
|
sender_user: Option<&UserId>,
|
||||||
|
|
@ -1265,7 +1264,7 @@ async fn validate_and_add_event_id(
|
||||||
Ok((event_id, value))
|
Ok((event_id, value))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
pub(crate) async fn invite_helper(
|
pub(crate) async fn invite_helper(
|
||||||
sender_user: &UserId,
|
sender_user: &UserId,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
|
|
@ -1571,7 +1570,7 @@ pub(crate) async fn leave_room(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
async fn remote_leave_room(user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
async fn remote_leave_room(user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
||||||
let mut make_leave_response_and_server = Err(Error::BadServerResponse(
|
let mut make_leave_response_and_server = Err(Error::BadServerResponse(
|
||||||
"No server available to assist in leaving.",
|
"No server available to assist in leaving.",
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ pub(crate) async fn send_message_event_route(
|
||||||
///
|
///
|
||||||
/// - Only works if the user is joined (TODO: always allow, but only show events
|
/// - Only works if the user is joined (TODO: always allow, but only show events
|
||||||
/// where the user was joined, depending on `history_visibility`)
|
/// where the user was joined, depending on `history_visibility`)
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
pub(crate) async fn get_message_events_route(
|
pub(crate) async fn get_message_events_route(
|
||||||
body: Ar<get_message_events::v3::Request>,
|
body: Ar<get_message_events::v3::Request>,
|
||||||
) -> Result<Ra<get_message_events::v3::Response>> {
|
) -> Result<Ra<get_message_events::v3::Response>> {
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ use crate::{
|
||||||
/// - Send events listed in initial state
|
/// - Send events listed in initial state
|
||||||
/// - Send events implied by `name` and `topic`
|
/// - Send events implied by `name` and `topic`
|
||||||
/// - Send invite events
|
/// - Send invite events
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
pub(crate) async fn create_room_route(
|
pub(crate) async fn create_room_route(
|
||||||
body: Ar<create_room::v3::Request>,
|
body: Ar<create_room::v3::Request>,
|
||||||
) -> Result<Ra<create_room::v3::Response>> {
|
) -> Result<Ra<create_room::v3::Response>> {
|
||||||
|
|
@ -570,7 +570,7 @@ pub(crate) async fn get_room_aliases_route(
|
||||||
/// - Transfers some state events
|
/// - Transfers some state events
|
||||||
/// - Moves local aliases
|
/// - Moves local aliases
|
||||||
/// - Modifies old room power levels to prevent users from speaking
|
/// - 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(
|
pub(crate) async fn upgrade_room_route(
|
||||||
body: Ar<upgrade_room::v3::Request>,
|
body: Ar<upgrade_room::v3::Request>,
|
||||||
) -> Result<Ra<upgrade_room::v3::Response>> {
|
) -> 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
|
/// - Only works if the user is currently joined to the room (TODO: Respect
|
||||||
/// history visibility)
|
/// history visibility)
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
pub(crate) async fn search_events_route(
|
pub(crate) async fn search_events_route(
|
||||||
body: Ar<search_events::v3::Request>,
|
body: Ar<search_events::v3::Request>,
|
||||||
) -> Result<Ra<search_events::v3::Response>> {
|
) -> 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
|
/// Note: You can use [`GET /_matrix/client/r0/login`](get_login_types_route) to
|
||||||
/// see supported login types.
|
/// see supported login types.
|
||||||
#[allow(
|
#[expect(deprecated, reason = "To allow deprecated login methods")]
|
||||||
// To allow deprecated login methods
|
#[expect(clippy::too_many_lines)]
|
||||||
deprecated,
|
|
||||||
clippy::too_many_lines,
|
|
||||||
)]
|
|
||||||
pub(crate) async fn login_route(
|
pub(crate) async fn login_route(
|
||||||
body: Ar<login::v3::Request>,
|
body: Ar<login::v3::Request>,
|
||||||
) -> Result<Ra<login::v3::Response>> {
|
) -> Result<Ra<login::v3::Response>> {
|
||||||
|
|
@ -252,8 +249,6 @@ pub(crate) async fn login_route(
|
||||||
|
|
||||||
info!(%user_id, %device_id, "User logged in");
|
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 {
|
Ok(Ra(login::v3::Response {
|
||||||
user_id,
|
user_id,
|
||||||
access_token: token,
|
access_token: token,
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ use crate::{
|
||||||
/// For left rooms:
|
/// For left rooms:
|
||||||
/// - If the user left after `since`: `prev_batch` token, empty state (TODO:
|
/// - If the user left after `since`: `prev_batch` token, empty state (TODO:
|
||||||
/// subset of the state at the point of the leave)
|
/// 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(
|
pub(crate) async fn sync_events_route(
|
||||||
body: Ar<sync_events::v3::Request>,
|
body: Ar<sync_events::v3::Request>,
|
||||||
) -> Result<Ra<sync_events::v3::Response>, Ra<UiaaResponse>> {
|
) -> Result<Ra<sync_events::v3::Response>, Ra<UiaaResponse>> {
|
||||||
|
|
@ -449,7 +449,7 @@ pub(crate) async fn sync_events_route(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all, fields(room_id = %room_id))]
|
#[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(
|
async fn load_joined_room(
|
||||||
sender_user: &UserId,
|
sender_user: &UserId,
|
||||||
sender_device: &DeviceId,
|
sender_device: &DeviceId,
|
||||||
|
|
@ -1121,7 +1121,7 @@ fn share_encrypted_room(
|
||||||
.any(|encrypted| encrypted))
|
.any(|encrypted| encrypted))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
pub(crate) async fn sync_events_v4_route(
|
pub(crate) async fn sync_events_v4_route(
|
||||||
body: Ar<sync_events::v4::Request>,
|
body: Ar<sync_events::v4::Request>,
|
||||||
) -> Result<Ra<sync_events::v4::Response>, Ra<UiaaResponse>> {
|
) -> Result<Ra<sync_events::v4::Response>, Ra<UiaaResponse>> {
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ struct ArPieces {
|
||||||
|
|
||||||
/// Non-generic part of [`Ar::from_request()`]. Splitting this out reduces
|
/// Non-generic part of [`Ar::from_request()`]. Splitting this out reduces
|
||||||
/// binary size by ~10%.
|
/// binary size by ~10%.
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
async fn ar_from_request_inner(
|
async fn ar_from_request_inner(
|
||||||
req: axum::extract::Request,
|
req: axum::extract::Request,
|
||||||
metadata: Metadata,
|
metadata: Metadata,
|
||||||
|
|
|
||||||
|
|
@ -372,7 +372,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>
|
/// 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
|
/// Numbers in comments below refer to bullet points in linked section of
|
||||||
/// specification
|
/// specification
|
||||||
#[allow(clippy::too_many_lines)]
|
|
||||||
#[tracing::instrument(ret(level = "debug"))]
|
#[tracing::instrument(ret(level = "debug"))]
|
||||||
async fn find_actual_destination(
|
async fn find_actual_destination(
|
||||||
destination: &'_ ServerName,
|
destination: &'_ ServerName,
|
||||||
|
|
@ -729,7 +728,7 @@ pub(crate) fn parse_incoming_pdu(
|
||||||
/// # `PUT /_matrix/federation/v1/send/{txnId}`
|
/// # `PUT /_matrix/federation/v1/send/{txnId}`
|
||||||
///
|
///
|
||||||
/// Push EDUs and PDUs to this server.
|
/// 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(
|
pub(crate) async fn send_transaction_message_route(
|
||||||
body: Ar<send_transaction_message::v1::Request>,
|
body: Ar<send_transaction_message::v1::Request>,
|
||||||
) -> Result<Ra<send_transaction_message::v1::Response>> {
|
) -> Result<Ra<send_transaction_message::v1::Response>> {
|
||||||
|
|
@ -1561,7 +1560,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(
|
async fn create_join_event(
|
||||||
sender_servername: &ServerName,
|
sender_servername: &ServerName,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
|
|
@ -1706,7 +1705,7 @@ async fn create_join_event(
|
||||||
/// # `PUT /_matrix/federation/v1/send_join/{roomId}/{eventId}`
|
/// # `PUT /_matrix/federation/v1/send_join/{roomId}/{eventId}`
|
||||||
///
|
///
|
||||||
/// Submits a signed join event.
|
/// Submits a signed join event.
|
||||||
#[allow(deprecated)]
|
#[expect(deprecated, reason = "support for deprecated API")]
|
||||||
pub(crate) async fn create_join_event_v1_route(
|
pub(crate) async fn create_join_event_v1_route(
|
||||||
body: Ar<create_join_event::v1::Request>,
|
body: Ar<create_join_event::v1::Request>,
|
||||||
) -> Result<Ra<create_join_event::v1::Response>> {
|
) -> Result<Ra<create_join_event::v1::Response>> {
|
||||||
|
|
@ -1750,7 +1749,7 @@ pub(crate) async fn create_join_event_v2_route(
|
||||||
/// # `PUT /_matrix/federation/v2/invite/{roomId}/{eventId}`
|
/// # `PUT /_matrix/federation/v2/invite/{roomId}/{eventId}`
|
||||||
///
|
///
|
||||||
/// Invites a remote user to a room.
|
/// Invites a remote user to a room.
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
pub(crate) async fn create_invite_route(
|
pub(crate) async fn create_invite_route(
|
||||||
body: Ar<create_invite::v2::Request>,
|
body: Ar<create_invite::v2::Request>,
|
||||||
) -> Result<Ra<create_invite::v2::Response>> {
|
) -> Result<Ra<create_invite::v2::Response>> {
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ async fn federation_self_test() -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
async fn run_server() -> Result<(), error::Serve> {
|
async fn run_server() -> Result<(), error::Serve> {
|
||||||
use error::Serve as Error;
|
use error::Serve as Error;
|
||||||
|
|
||||||
|
|
@ -337,7 +337,7 @@ fn legacy_media_routes(config: &Config) -> Router {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines, reason = "there's a lot of routes")]
|
||||||
fn client_routes() -> Router {
|
fn client_routes() -> Router {
|
||||||
use client_server as c2s;
|
use client_server as c2s;
|
||||||
|
|
||||||
|
|
@ -705,7 +705,6 @@ pub(crate) trait RumaHandler<T> {
|
||||||
macro_rules! impl_ruma_handler {
|
macro_rules! impl_ruma_handler {
|
||||||
( $($ty:ident),* $(,)? ) => {
|
( $($ty:ident),* $(,)? ) => {
|
||||||
#[axum::async_trait]
|
#[axum::async_trait]
|
||||||
#[allow(non_snake_case)]
|
|
||||||
impl<Req, Resp, E, F, Fut, $($ty,)*>
|
impl<Req, Resp, E, F, Fut, $($ty,)*>
|
||||||
RumaHandler<($($ty,)* Ar<Req>,)> for F
|
RumaHandler<($($ty,)* Ar<Req>,)> for F
|
||||||
where
|
where
|
||||||
|
|
@ -728,7 +727,10 @@ macro_rules! impl_ruma_handler {
|
||||||
path,
|
path,
|
||||||
on(
|
on(
|
||||||
method_filter,
|
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!(
|
let span = info_span!(
|
||||||
"run_ruma_handler",
|
"run_ruma_handler",
|
||||||
auth.user = ?req.sender_user,
|
auth.user = ?req.sender_user,
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ use proxy::ProxyConfig;
|
||||||
pub(crate) static DEFAULT_PATH: Lazy<PathBuf> =
|
pub(crate) static DEFAULT_PATH: Lazy<PathBuf> =
|
||||||
Lazy::new(|| [env!("CARGO_PKG_NAME"), "config.toml"].iter().collect());
|
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)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub(crate) struct Config {
|
pub(crate) struct Config {
|
||||||
#[serde(default = "false_fn")]
|
#[serde(default = "false_fn")]
|
||||||
|
|
|
||||||
|
|
@ -95,13 +95,17 @@ pub(crate) struct KeyValueDatabase {
|
||||||
pub(super) roomuserid_lastprivatereadupdate: Arc<dyn KvTree>,
|
pub(super) roomuserid_lastprivatereadupdate: Arc<dyn KvTree>,
|
||||||
|
|
||||||
// PresenceId = RoomId + Count + UserId
|
// PresenceId = RoomId + Count + UserId
|
||||||
// This exists in the database already but is currently unused
|
#[expect(
|
||||||
#[allow(dead_code)]
|
dead_code,
|
||||||
|
reason = "This exists in the database already but is currently unused"
|
||||||
|
)]
|
||||||
pub(super) presenceid_presence: Arc<dyn KvTree>,
|
pub(super) presenceid_presence: Arc<dyn KvTree>,
|
||||||
|
|
||||||
// LastPresenceUpdate = Count
|
// LastPresenceUpdate = Count
|
||||||
// This exists in the database already but is currently unused
|
#[expect(
|
||||||
#[allow(dead_code)]
|
dead_code,
|
||||||
|
reason = "This exists in the database already but is currently unused"
|
||||||
|
)]
|
||||||
pub(super) userid_lastpresenceupdate: Arc<dyn KvTree>,
|
pub(super) userid_lastpresenceupdate: Arc<dyn KvTree>,
|
||||||
|
|
||||||
// Trees "owned" by `self::key_value::rooms`
|
// Trees "owned" by `self::key_value::rooms`
|
||||||
|
|
@ -317,7 +321,7 @@ impl KeyValueDatabase {
|
||||||
not(any(feature = "rocksdb", feature = "sqlite")),
|
not(any(feature = "rocksdb", feature = "sqlite")),
|
||||||
allow(unreachable_code)
|
allow(unreachable_code)
|
||||||
)]
|
)]
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
pub(crate) fn load_or_create(config: &Config) -> Result<KeyValueDatabase> {
|
pub(crate) fn load_or_create(config: &Config) -> Result<KeyValueDatabase> {
|
||||||
Self::check_db_setup(config)?;
|
Self::check_db_setup(config)?;
|
||||||
|
|
||||||
|
|
@ -478,7 +482,7 @@ impl KeyValueDatabase {
|
||||||
.try_into()
|
.try_into()
|
||||||
.expect("pdu cache capacity fits into usize"),
|
.expect("pdu cache capacity fits into usize"),
|
||||||
)),
|
)),
|
||||||
#[allow(
|
#[expect(
|
||||||
clippy::as_conversions,
|
clippy::as_conversions,
|
||||||
clippy::cast_sign_loss,
|
clippy::cast_sign_loss,
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation
|
||||||
|
|
@ -486,7 +490,7 @@ impl KeyValueDatabase {
|
||||||
auth_chain_cache: Mutex::new(LruCache::new(
|
auth_chain_cache: Mutex::new(LruCache::new(
|
||||||
(100_000.0 * config.cache_capacity_modifier) as usize,
|
(100_000.0 * config.cache_capacity_modifier) as usize,
|
||||||
)),
|
)),
|
||||||
#[allow(
|
#[expect(
|
||||||
clippy::as_conversions,
|
clippy::as_conversions,
|
||||||
clippy::cast_sign_loss,
|
clippy::cast_sign_loss,
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation
|
||||||
|
|
@ -494,7 +498,7 @@ impl KeyValueDatabase {
|
||||||
shorteventid_cache: Mutex::new(LruCache::new(
|
shorteventid_cache: Mutex::new(LruCache::new(
|
||||||
(100_000.0 * config.cache_capacity_modifier) as usize,
|
(100_000.0 * config.cache_capacity_modifier) as usize,
|
||||||
)),
|
)),
|
||||||
#[allow(
|
#[expect(
|
||||||
clippy::as_conversions,
|
clippy::as_conversions,
|
||||||
clippy::cast_sign_loss,
|
clippy::cast_sign_loss,
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation
|
||||||
|
|
@ -502,7 +506,7 @@ impl KeyValueDatabase {
|
||||||
eventidshort_cache: Mutex::new(LruCache::new(
|
eventidshort_cache: Mutex::new(LruCache::new(
|
||||||
(100_000.0 * config.cache_capacity_modifier) as usize,
|
(100_000.0 * config.cache_capacity_modifier) as usize,
|
||||||
)),
|
)),
|
||||||
#[allow(
|
#[expect(
|
||||||
clippy::as_conversions,
|
clippy::as_conversions,
|
||||||
clippy::cast_sign_loss,
|
clippy::cast_sign_loss,
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation
|
||||||
|
|
@ -510,7 +514,7 @@ impl KeyValueDatabase {
|
||||||
shortstatekey_cache: Mutex::new(LruCache::new(
|
shortstatekey_cache: Mutex::new(LruCache::new(
|
||||||
(100_000.0 * config.cache_capacity_modifier) as usize,
|
(100_000.0 * config.cache_capacity_modifier) as usize,
|
||||||
)),
|
)),
|
||||||
#[allow(
|
#[expect(
|
||||||
clippy::as_conversions,
|
clippy::as_conversions,
|
||||||
clippy::cast_sign_loss,
|
clippy::cast_sign_loss,
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation
|
||||||
|
|
@ -531,7 +535,7 @@ impl KeyValueDatabase {
|
||||||
///
|
///
|
||||||
/// If it is not possible to migrate the database to the current version,
|
/// If it is not possible to migrate the database to the current version,
|
||||||
/// returns an error.
|
/// returns an error.
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
pub(crate) async fn apply_migrations(&self) -> Result<()> {
|
pub(crate) async fn apply_migrations(&self) -> Result<()> {
|
||||||
// If the database has any data, perform data migrations before starting
|
// If the database has any data, perform data migrations before starting
|
||||||
let latest_database_version = 13;
|
let latest_database_version = 13;
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,11 @@ fn db_options(max_open_files: i32, rocksdb_cache: &Cache) -> Options {
|
||||||
|
|
||||||
impl KeyValueDatabaseEngine for Arc<Engine> {
|
impl KeyValueDatabaseEngine for Arc<Engine> {
|
||||||
fn open(config: &Config) -> Result<Self> {
|
fn open(config: &Config) -> Result<Self> {
|
||||||
#[allow(
|
#[expect(
|
||||||
clippy::as_conversions,
|
clippy::as_conversions,
|
||||||
clippy::cast_sign_loss,
|
clippy::cast_sign_loss,
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation,
|
||||||
|
reason = "saturating to usize is fine"
|
||||||
)]
|
)]
|
||||||
let cache_capacity_bytes =
|
let cache_capacity_bytes =
|
||||||
(config.database.cache_capacity_mb * 1024.0 * 1024.0) as usize;
|
(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> {
|
fn memory_usage(&self) -> Result<String> {
|
||||||
let stats =
|
let stats =
|
||||||
get_memory_usage_stats(Some(&[&self.rocks]), Some(&[&self.cache]))?;
|
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 +
|
// 2. divide by permanent connections + permanent iter connections +
|
||||||
// write connection
|
// write connection
|
||||||
// 3. round down to nearest integer
|
// 3. round down to nearest integer
|
||||||
#[allow(
|
#[expect(
|
||||||
clippy::as_conversions,
|
clippy::as_conversions,
|
||||||
clippy::cast_possible_truncation,
|
clippy::cast_possible_truncation,
|
||||||
clippy::cast_precision_loss,
|
clippy::cast_precision_loss,
|
||||||
clippy::cast_sign_loss
|
clippy::cast_sign_loss,
|
||||||
|
reason = "saturating to u32 is fine"
|
||||||
)]
|
)]
|
||||||
let cache_size_per_thread =
|
let cache_size_per_thread =
|
||||||
((config.database.cache_capacity_mb * 1024.0)
|
((config.database.cache_capacity_mb * 1024.0)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,10 @@ use tokio::sync::watch;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(super) struct Watchers {
|
pub(super) struct Watchers {
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(
|
||||||
|
clippy::type_complexity,
|
||||||
|
reason = "not actually all that complex"
|
||||||
|
)]
|
||||||
watchers:
|
watchers:
|
||||||
RwLock<HashMap<Vec<u8>, (watch::Sender<()>, watch::Receiver<()>)>>,
|
RwLock<HashMap<Vec<u8>, (watch::Sender<()>, watch::Receiver<()>)>>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ impl service::rooms::edus::read_receipt::Data for KeyValueDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
fn readreceipts_since<'a>(
|
fn readreceipts_since<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ impl service::rooms::search::Data for KeyValueDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
fn search_pdus<'a>(
|
fn search_pdus<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
room_id: &RoomId,
|
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.
|
/// Returns an iterator over all rooms a user was invited to.
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
fn rooms_invited<'a>(
|
fn rooms_invited<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
|
@ -575,7 +575,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over all rooms a user left.
|
/// Returns an iterator over all rooms a user left.
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
fn rooms_left<'a>(
|
fn rooms_left<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
|
|
||||||
21
src/error.rs
21
src/error.rs
|
|
@ -35,9 +35,6 @@ impl fmt::Display for DisplayWithSources<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Top-level errors
|
/// 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)]
|
#[derive(Error, Debug)]
|
||||||
pub(crate) enum Main {
|
pub(crate) enum Main {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
|
|
@ -45,9 +42,6 @@ pub(crate) enum Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Errors returned from the `serve` CLI subcommand.
|
/// Errors returned from the `serve` CLI subcommand.
|
||||||
// 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)]
|
#[derive(Error, Debug)]
|
||||||
pub(crate) enum ServeCommand {
|
pub(crate) enum ServeCommand {
|
||||||
#[error("failed to load configuration")]
|
#[error("failed to load configuration")]
|
||||||
|
|
@ -70,9 +64,6 @@ pub(crate) enum ServeCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error generated if `server_name` has changed or if checking this failed
|
/// Error generated if `server_name` has changed or if checking this failed
|
||||||
// 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)]
|
#[derive(Error, Debug)]
|
||||||
pub(crate) enum ServerNameChanged {
|
pub(crate) enum ServerNameChanged {
|
||||||
#[error("failed to check if there are any users")]
|
#[error("failed to check if there are any users")]
|
||||||
|
|
@ -86,9 +77,6 @@ pub(crate) enum ServerNameChanged {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Observability initialization errors
|
/// 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)]
|
#[derive(Error, Debug)]
|
||||||
pub(crate) enum Observability {
|
pub(crate) enum Observability {
|
||||||
// Upstream's documentation on what this error means is very sparse
|
// Upstream's documentation on what this error means is very sparse
|
||||||
|
|
@ -104,9 +92,6 @@ pub(crate) enum Observability {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration errors
|
/// 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)]
|
#[derive(Error, Debug)]
|
||||||
pub(crate) enum Config {
|
pub(crate) enum Config {
|
||||||
#[error("failed to find configuration file")]
|
#[error("failed to find configuration file")]
|
||||||
|
|
@ -123,9 +108,6 @@ pub(crate) enum Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Errors that can occur while searching for a config file
|
/// 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)]
|
#[derive(Error, Debug)]
|
||||||
pub(crate) enum ConfigSearch {
|
pub(crate) enum ConfigSearch {
|
||||||
#[error("XDG Base Directory error")]
|
#[error("XDG Base Directory error")]
|
||||||
|
|
@ -136,9 +118,6 @@ pub(crate) enum ConfigSearch {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Errors serving traffic
|
/// 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)]
|
#[derive(Error, Debug)]
|
||||||
pub(crate) enum Serve {
|
pub(crate) enum Serve {
|
||||||
#[error("no listeners were specified in the configuration file")]
|
#[error("no listeners were specified in the configuration file")]
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ pub(crate) static METRICS: Lazy<Metrics> = Lazy::new(Metrics::new);
|
||||||
/// Cleans up resources relating to observability when [`Drop`]ped
|
/// Cleans up resources relating to observability when [`Drop`]ped
|
||||||
pub(crate) struct Guard {
|
pub(crate) struct Guard {
|
||||||
/// Drop guard used to flush [`tracing_flame`] data on exit
|
/// 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>>>,
|
flame_guard: Option<FlushGuard<BufWriter<File>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,7 +80,10 @@ pub(crate) type FilterReloadHandle = Box<dyn ReloadHandle<EnvFilter> + Sync>;
|
||||||
/// Collection of [`FilterReloadHandle`]s, allowing the filters for tracing
|
/// Collection of [`FilterReloadHandle`]s, allowing the filters for tracing
|
||||||
/// backends to be changed dynamically. Handles may be [`None`] if the backend
|
/// backends to be changed dynamically. Handles may be [`None`] if the backend
|
||||||
/// is disabled in the config.
|
/// 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) struct FilterReloadHandles {
|
||||||
pub(crate) traces: Option<FilterReloadHandle>,
|
pub(crate) traces: Option<FilterReloadHandle>,
|
||||||
pub(crate) flame: Option<FilterReloadHandle>,
|
pub(crate) flame: Option<FilterReloadHandle>,
|
||||||
|
|
@ -91,7 +94,7 @@ pub(crate) struct FilterReloadHandles {
|
||||||
///
|
///
|
||||||
/// See also [`Metrics::record_lookup`].
|
/// See also [`Metrics::record_lookup`].
|
||||||
// Keep variants sorted
|
// Keep variants sorted
|
||||||
#[allow(clippy::missing_docs_in_private_items)]
|
#[expect(clippy::missing_docs_in_private_items)]
|
||||||
#[derive(Clone, Copy, AsRefStr, IntoStaticStr)]
|
#[derive(Clone, Copy, AsRefStr, IntoStaticStr)]
|
||||||
pub(crate) enum Lookup {
|
pub(crate) enum Lookup {
|
||||||
AppserviceInRoom,
|
AppserviceInRoom,
|
||||||
|
|
@ -208,7 +211,7 @@ pub(crate) fn init(
|
||||||
let (log_layer, log_filter, _) =
|
let (log_layer, log_filter, _) =
|
||||||
make_backend(true, &config.observability.logs.filter, || {
|
make_backend(true, &config.observability.logs.filter, || {
|
||||||
/// Time format selection for `tracing_subscriber` at runtime
|
/// 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 {
|
enum TimeFormat {
|
||||||
SystemTime,
|
SystemTime,
|
||||||
NoTime,
|
NoTime,
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ impl Services {
|
||||||
},
|
},
|
||||||
state_accessor: rooms::state_accessor::Service {
|
state_accessor: rooms::state_accessor::Service {
|
||||||
db,
|
db,
|
||||||
#[allow(
|
#[expect(
|
||||||
clippy::as_conversions,
|
clippy::as_conversions,
|
||||||
clippy::cast_sign_loss,
|
clippy::cast_sign_loss,
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation
|
||||||
|
|
@ -107,7 +107,7 @@ impl Services {
|
||||||
server_visibility_cache: StdMutex::new(LruCache::new(
|
server_visibility_cache: StdMutex::new(LruCache::new(
|
||||||
(100.0 * config.cache_capacity_modifier) as usize,
|
(100.0 * config.cache_capacity_modifier) as usize,
|
||||||
)),
|
)),
|
||||||
#[allow(
|
#[expect(
|
||||||
clippy::as_conversions,
|
clippy::as_conversions,
|
||||||
clippy::cast_sign_loss,
|
clippy::cast_sign_loss,
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation
|
||||||
|
|
@ -121,7 +121,7 @@ impl Services {
|
||||||
},
|
},
|
||||||
state_compressor: rooms::state_compressor::Service {
|
state_compressor: rooms::state_compressor::Service {
|
||||||
db,
|
db,
|
||||||
#[allow(
|
#[expect(
|
||||||
clippy::as_conversions,
|
clippy::as_conversions,
|
||||||
clippy::cast_sign_loss,
|
clippy::cast_sign_loss,
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,10 @@ enum AdminCommand {
|
||||||
/// # ```
|
/// # ```
|
||||||
/// # yaml content here
|
/// # yaml content here
|
||||||
/// # ```
|
/// # ```
|
||||||
// Allowed because the doc comment gets parsed by our code later
|
#[expect(
|
||||||
#[allow(clippy::doc_markdown)]
|
clippy::doc_markdown,
|
||||||
|
reason = "the doc comment gets parsed by our code later"
|
||||||
|
)]
|
||||||
RegisterAppservice,
|
RegisterAppservice,
|
||||||
|
|
||||||
/// Unregister an appservice using its ID
|
/// Unregister an appservice using its ID
|
||||||
|
|
@ -104,8 +106,10 @@ enum AdminCommand {
|
||||||
/// # ```
|
/// # ```
|
||||||
/// # User list here
|
/// # User list here
|
||||||
/// # ```
|
/// # ```
|
||||||
// Allowed because the doc comment gets parsed by our code later
|
#[expect(
|
||||||
#[allow(clippy::doc_markdown)]
|
clippy::doc_markdown,
|
||||||
|
reason = "the doc comment gets parsed by our code later"
|
||||||
|
)]
|
||||||
DeactivateAll {
|
DeactivateAll {
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
/// Remove users from their joined rooms
|
/// Remove users from their joined rooms
|
||||||
|
|
@ -131,8 +135,10 @@ enum AdminCommand {
|
||||||
/// # ```
|
/// # ```
|
||||||
/// # PDU json content here
|
/// # PDU json content here
|
||||||
/// # ```
|
/// # ```
|
||||||
// Allowed because the doc comment gets parsed by our code later
|
#[expect(
|
||||||
#[allow(clippy::doc_markdown)]
|
clippy::doc_markdown,
|
||||||
|
reason = "the doc comment gets parsed by our code later"
|
||||||
|
)]
|
||||||
ParsePdu,
|
ParsePdu,
|
||||||
|
|
||||||
/// Retrieve and print a PDU by ID from the Grapevine database
|
/// Retrieve and print a PDU by ID from the Grapevine database
|
||||||
|
|
@ -206,8 +212,10 @@ enum AdminCommand {
|
||||||
/// # ```
|
/// # ```
|
||||||
/// # json here
|
/// # json here
|
||||||
/// # ```
|
/// # ```
|
||||||
// Allowed because the doc comment gets parsed by our code later
|
#[expect(
|
||||||
#[allow(clippy::doc_markdown)]
|
clippy::doc_markdown,
|
||||||
|
reason = "the doc comment gets parsed by our code later"
|
||||||
|
)]
|
||||||
SignJson,
|
SignJson,
|
||||||
|
|
||||||
/// Verify json signatures
|
/// Verify json signatures
|
||||||
|
|
@ -215,8 +223,10 @@ enum AdminCommand {
|
||||||
/// # ```
|
/// # ```
|
||||||
/// # json here
|
/// # json here
|
||||||
/// # ```
|
/// # ```
|
||||||
// Allowed because the doc comment gets parsed by our code later
|
#[expect(
|
||||||
#[allow(clippy::doc_markdown)]
|
clippy::doc_markdown,
|
||||||
|
reason = "the doc comment gets parsed by our code later"
|
||||||
|
)]
|
||||||
VerifyJson,
|
VerifyJson,
|
||||||
|
|
||||||
/// Dynamically change a tracing backend's filter string
|
/// Dynamically change a tracing backend's filter string
|
||||||
|
|
@ -411,7 +421,6 @@ impl Service {
|
||||||
AdminCommand::try_parse_from(argv).map_err(|error| error.to_string())
|
AdminCommand::try_parse_from(argv).map_err(|error| error.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
|
||||||
#[tracing::instrument(skip(self, body))]
|
#[tracing::instrument(skip(self, body))]
|
||||||
async fn process_admin_command(
|
async fn process_admin_command(
|
||||||
&self,
|
&self,
|
||||||
|
|
@ -1286,7 +1295,6 @@ impl Service {
|
||||||
/// Users in this room are considered admins by grapevine, and the room can
|
/// 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
|
/// be used to issue admin commands by talking to the server user inside
|
||||||
/// it.
|
/// it.
|
||||||
#[allow(clippy::too_many_lines)]
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub(crate) async fn create_admin_room(&self) -> Result<()> {
|
pub(crate) async fn create_admin_room(&self) -> Result<()> {
|
||||||
let room_id = RoomId::new(services().globals.server_name());
|
let room_id = RoomId::new(services().globals.server_name());
|
||||||
|
|
@ -1527,8 +1535,7 @@ impl Service {
|
||||||
///
|
///
|
||||||
/// Errors are propagated from the database, and will have None if there is
|
/// Errors are propagated from the database, and will have None if there is
|
||||||
/// no admin room
|
/// no admin room
|
||||||
// Allowed because this function uses `services()`
|
#[expect(clippy::unused_self, reason = "uses services()")]
|
||||||
#[allow(clippy::unused_self)]
|
|
||||||
pub(crate) fn get_admin_room(&self) -> Result<Option<OwnedRoomId>> {
|
pub(crate) fn get_admin_room(&self) -> Result<Option<OwnedRoomId>> {
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ pub(crate) struct RotationHandler(
|
||||||
// TODO: Determine if it's safe to delete this field. I'm not deleting it
|
// 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
|
// right now because I'm unsure what implications that would have for how
|
||||||
// the sender expects to work.
|
// the sender expects to work.
|
||||||
#[allow(dead_code)] broadcast::Receiver<()>,
|
#[expect(dead_code, reason = "see comment")] broadcast::Receiver<()>,
|
||||||
);
|
);
|
||||||
|
|
||||||
impl RotationHandler {
|
impl RotationHandler {
|
||||||
|
|
@ -310,8 +310,6 @@ impl Service {
|
||||||
/// Matrix resource ownership is based on the server name; changing it
|
/// Matrix resource ownership is based on the server name; changing it
|
||||||
/// requires recreating the database from scratch. This check needs to be
|
/// requires recreating the database from scratch. This check needs to be
|
||||||
/// done before background tasks are started to avoid data races.
|
/// done before background tasks are started to avoid data races.
|
||||||
// Allowed because this function calls `services()`
|
|
||||||
#[allow(clippy::unused_self)]
|
|
||||||
pub(crate) fn err_if_server_name_changed(
|
pub(crate) fn err_if_server_name_changed(
|
||||||
&self,
|
&self,
|
||||||
) -> Result<(), crate::error::ServerNameChanged> {
|
) -> Result<(), crate::error::ServerNameChanged> {
|
||||||
|
|
@ -544,7 +542,6 @@ impl Service {
|
||||||
/// Filters the key map of multiple servers down to keys that should be
|
/// Filters the key map of multiple servers down to keys that should be
|
||||||
/// accepted given the expiry time, room version, and timestamp of the
|
/// accepted given the expiry time, room version, and timestamp of the
|
||||||
/// paramters
|
/// paramters
|
||||||
#[allow(clippy::unused_self)]
|
|
||||||
pub(crate) fn filter_keys_server_map(
|
pub(crate) fn filter_keys_server_map(
|
||||||
&self,
|
&self,
|
||||||
keys: BTreeMap<String, SigningKeys>,
|
keys: BTreeMap<String, SigningKeys>,
|
||||||
|
|
@ -561,7 +558,7 @@ impl Service {
|
||||||
|
|
||||||
/// Filters the keys of a single server down to keys that should be accepted
|
/// 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
|
/// given the expiry time, room version, and timestamp of the paramters
|
||||||
#[allow(clippy::unused_self)]
|
#[expect(clippy::unused_self)]
|
||||||
pub(crate) fn filter_keys_single_server(
|
pub(crate) fn filter_keys_single_server(
|
||||||
&self,
|
&self,
|
||||||
keys: SigningKeys,
|
keys: SigningKeys,
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ pub(crate) struct FileMeta {
|
||||||
//
|
//
|
||||||
// TODO: Write a database migration to get rid of this and instead store
|
// TODO: Write a database migration to get rid of this and instead store
|
||||||
// only the filename instead of the entire `Content-Disposition` header.
|
// only the filename instead of the entire `Content-Disposition` header.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) content_disposition: Option<String>,
|
pub(crate) content_disposition: Option<String>,
|
||||||
pub(crate) content_type: Option<String>,
|
pub(crate) content_type: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,13 @@ impl Service {
|
||||||
for id in starting_events {
|
for id in starting_events {
|
||||||
let short =
|
let short =
|
||||||
services().rooms.short.get_or_create_shorteventid(&id)?;
|
services().rooms.short.get_or_create_shorteventid(&id)?;
|
||||||
// I'm afraid to change this in case there is accidental reliance on
|
#[expect(
|
||||||
// the truncation
|
clippy::as_conversions,
|
||||||
#[allow(clippy::as_conversions, clippy::cast_possible_truncation)]
|
clippy::cast_possible_truncation,
|
||||||
|
reason = "I'm afraid to change this in case there is \
|
||||||
|
accidental
|
||||||
|
reliance on the truncation"
|
||||||
|
)]
|
||||||
let bucket_id = (short.get() % NUM_BUCKETS as u64) as usize;
|
let bucket_id = (short.get() % NUM_BUCKETS as u64) as usize;
|
||||||
buckets[bucket_id].insert((short, id.clone()));
|
buckets[bucket_id].insert((short, id.clone()));
|
||||||
i += 1;
|
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
|
/// Returns an iterator over the most recent read receipts in a room that
|
||||||
/// happened after the event with id `since`.
|
/// happened after the event with id `since`.
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
fn readreceipts_since<'a>(
|
fn readreceipts_since<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
|
|
@ -40,7 +40,7 @@ pub(crate) trait Data: Send + Sync {
|
||||||
|
|
||||||
/// Returns the private read marker.
|
/// Returns the private read marker.
|
||||||
// TODO: Implement MSC2285
|
// TODO: Implement MSC2285
|
||||||
#[allow(dead_code)]
|
#[expect(dead_code, reason = "private read receipts are unimplemented")]
|
||||||
fn private_read_get(
|
fn private_read_get(
|
||||||
&self,
|
&self,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
|
|
@ -49,7 +49,7 @@ pub(crate) trait Data: Send + Sync {
|
||||||
|
|
||||||
/// Returns the count of the last typing update in this room.
|
/// Returns the count of the last typing update in this room.
|
||||||
// TODO: Implement MSC2285
|
// TODO: Implement MSC2285
|
||||||
#[allow(dead_code)]
|
#[expect(dead_code, reason = "private read receipts are unimplemented")]
|
||||||
fn last_privateread_update(
|
fn last_privateread_update(
|
||||||
&self,
|
&self,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ impl Service {
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[expect(clippy::too_many_arguments)]
|
||||||
#[tracing::instrument(skip(self, origin, room_id, value, pub_key_map))]
|
#[tracing::instrument(skip(self, origin, room_id, value, pub_key_map))]
|
||||||
fn handle_outlier_pdu<'a>(
|
fn handle_outlier_pdu<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
|
@ -1433,7 +1433,7 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
async fn fetch_unknown_prev_events(
|
async fn fetch_unknown_prev_events(
|
||||||
&self,
|
&self,
|
||||||
origin: &ServerName,
|
origin: &ServerName,
|
||||||
|
|
@ -1709,7 +1709,7 @@ impl Service {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
pub(crate) async fn fetch_join_signing_keys(
|
pub(crate) async fn fetch_join_signing_keys(
|
||||||
&self,
|
&self,
|
||||||
event: &create_join_event::v2::Response,
|
event: &create_join_event::v2::Response,
|
||||||
|
|
@ -1840,8 +1840,6 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns Ok if the acl allows the server
|
/// Returns Ok if the acl allows the server
|
||||||
// Allowed because this function uses `services()`
|
|
||||||
#[allow(clippy::unused_self)]
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
pub(crate) fn acl_check(
|
pub(crate) fn acl_check(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use crate::Result;
|
||||||
pub(crate) struct Service {
|
pub(crate) struct Service {
|
||||||
pub(crate) db: &'static dyn Data,
|
pub(crate) db: &'static dyn Data,
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
pub(crate) lazy_load_waiting: Mutex<
|
pub(crate) lazy_load_waiting: Mutex<
|
||||||
HashMap<
|
HashMap<
|
||||||
(OwnedUserId, OwnedDeviceId, OwnedRoomId, PduCount),
|
(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))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub(crate) fn paginate_relations_with_filter(
|
pub(crate) fn paginate_relations_with_filter(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use crate::{
|
||||||
|
|
||||||
pub(crate) trait Data: Send + Sync {
|
pub(crate) trait Data: Send + Sync {
|
||||||
fn add_relation(&self, from: u64, to: u64) -> Result<()>;
|
fn add_relation(&self, from: u64, to: u64) -> Result<()>;
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
fn relations_until<'a>(
|
fn relations_until<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
user_id: &'a UserId,
|
user_id: &'a UserId,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ pub(crate) trait Data: Send + Sync {
|
||||||
message_body: &str,
|
message_body: &str,
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
fn search_pdus<'a>(
|
fn search_pdus<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,6 @@ pub(crate) struct Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
#[allow(clippy::too_many_lines)]
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub(crate) async fn get_hierarchy(
|
pub(crate) async fn get_hierarchy(
|
||||||
&self,
|
&self,
|
||||||
|
|
@ -326,7 +325,6 @@ impl Service {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
|
||||||
#[tracing::instrument(skip(self, children))]
|
#[tracing::instrument(skip(self, children))]
|
||||||
fn get_room_chunk(
|
fn get_room_chunk(
|
||||||
&self,
|
&self,
|
||||||
|
|
@ -532,8 +530,7 @@ impl Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allowed because this function uses `services()`
|
#[expect(clippy::unused_self, reason = "uses services()")]
|
||||||
#[allow(clippy::unused_self)]
|
|
||||||
fn handle_simplified_join_rule(
|
fn handle_simplified_join_rule(
|
||||||
&self,
|
&self,
|
||||||
join_rule: &SpaceRoomJoinRule,
|
join_rule: &SpaceRoomJoinRule,
|
||||||
|
|
|
||||||
|
|
@ -396,8 +396,6 @@ impl Service {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allowed because this function uses `services()`
|
|
||||||
#[allow(clippy::unused_self)]
|
|
||||||
#[tracing::instrument(skip(self), ret(level = "trace"))]
|
#[tracing::instrument(skip(self), ret(level = "trace"))]
|
||||||
pub(crate) fn user_can_invite(
|
pub(crate) fn user_can_invite(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -175,8 +175,7 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Copy `m.tag` account data to an upgraded room.
|
/// Copy `m.tag` account data to an upgraded room.
|
||||||
// Allowed because this function uses `services()`
|
#[expect(clippy::unused_self, reason = "uses services()")]
|
||||||
#[allow(clippy::unused_self)]
|
|
||||||
fn copy_upgraded_account_data_tag(
|
fn copy_upgraded_account_data_tag(
|
||||||
&self,
|
&self,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
|
|
@ -206,8 +205,7 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Copy references in `m.direct` account data events to an upgraded room.
|
/// Copy references in `m.direct` account data events to an upgraded room.
|
||||||
// Allowed because this function uses `services()`
|
#[expect(clippy::unused_self, reason = "uses services()")]
|
||||||
#[allow(clippy::unused_self)]
|
|
||||||
fn copy_upgraded_account_data_direct(
|
fn copy_upgraded_account_data_direct(
|
||||||
&self,
|
&self,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ pub(crate) trait Data: Send + Sync {
|
||||||
) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a>;
|
) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a>;
|
||||||
|
|
||||||
/// Returns an iterator over all rooms a user was invited to.
|
/// Returns an iterator over all rooms a user was invited to.
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
fn rooms_invited<'a>(
|
fn rooms_invited<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
|
|
@ -116,7 +116,7 @@ pub(crate) trait Data: Send + Sync {
|
||||||
) -> Result<Option<Vec<Raw<AnyStrippedStateEvent>>>>;
|
) -> Result<Option<Vec<Raw<AnyStrippedStateEvent>>>>;
|
||||||
|
|
||||||
/// Returns an iterator over all rooms a user left.
|
/// Returns an iterator over all rooms a user left.
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
fn rooms_left<'a>(
|
fn rooms_left<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
user_id: &UserId,
|
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>;
|
fn is_invited(&self, user_id: &UserId, room_id: &RoomId) -> Result<bool>;
|
||||||
|
|
||||||
// TODO: Use this when implementing sync filtering
|
// 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>;
|
fn is_left(&self, user_id: &UserId, room_id: &RoomId) -> Result<bool>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ pub(crate) struct CompressedStateLayer {
|
||||||
pub(crate) struct Service {
|
pub(crate) struct Service {
|
||||||
pub(crate) db: &'static dyn Data,
|
pub(crate) db: &'static dyn Data,
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
|
||||||
pub(crate) stateinfo_cache:
|
pub(crate) stateinfo_cache:
|
||||||
Mutex<LruCache<ShortStateHash, Vec<CompressedStateLayer>>>,
|
Mutex<LruCache<ShortStateHash, Vec<CompressedStateLayer>>>,
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +74,6 @@ impl CompressedStateEvent {
|
||||||
impl Service {
|
impl Service {
|
||||||
/// Returns a stack with info on shortstatehash, full state, added diff and
|
/// Returns a stack with info on shortstatehash, full state, added diff and
|
||||||
/// removed diff for the selected shortstatehash and each parent layer.
|
/// removed diff for the selected shortstatehash and each parent layer.
|
||||||
#[allow(clippy::type_complexity)]
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub(crate) fn load_shortstatehash_info(
|
pub(crate) fn load_shortstatehash_info(
|
||||||
&self,
|
&self,
|
||||||
|
|
@ -130,8 +128,7 @@ impl Service {
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allowed because this function uses `services()`
|
#[expect(clippy::unused_self, reason = "uses services()")]
|
||||||
#[allow(clippy::unused_self)]
|
|
||||||
pub(crate) fn compress_state_event(
|
pub(crate) fn compress_state_event(
|
||||||
&self,
|
&self,
|
||||||
shortstatekey: ShortStateKey,
|
shortstatekey: ShortStateKey,
|
||||||
|
|
@ -147,8 +144,7 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns shortstatekey, event id
|
/// Returns shortstatekey, event id
|
||||||
// Allowed because this function uses `services()`
|
#[expect(clippy::unused_self, reason = "uses services()")]
|
||||||
#[allow(clippy::unused_self)]
|
|
||||||
pub(crate) fn parse_compressed_state_event(
|
pub(crate) fn parse_compressed_state_event(
|
||||||
&self,
|
&self,
|
||||||
compressed_event: &CompressedStateEvent,
|
compressed_event: &CompressedStateEvent,
|
||||||
|
|
@ -180,7 +176,6 @@ impl Service {
|
||||||
/// for this layer
|
/// for this layer
|
||||||
/// * `parent_states` - A stack with info on shortstatehash, full state,
|
/// * `parent_states` - A stack with info on shortstatehash, full state,
|
||||||
/// added diff and removed diff for each parent layer
|
/// added diff and removed diff for each parent layer
|
||||||
#[allow(clippy::type_complexity)]
|
|
||||||
#[tracing::instrument(skip(
|
#[tracing::instrument(skip(
|
||||||
self,
|
self,
|
||||||
statediffnew,
|
statediffnew,
|
||||||
|
|
@ -303,7 +298,7 @@ impl Service {
|
||||||
|
|
||||||
/// Returns the new shortstatehash, and the state diff from the previous
|
/// Returns the new shortstatehash, and the state diff from the previous
|
||||||
/// room state
|
/// room state
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
#[tracing::instrument(skip(self, new_state_ids_compressed))]
|
#[tracing::instrument(skip(self, new_state_ids_compressed))]
|
||||||
pub(crate) fn save_state(
|
pub(crate) fn save_state(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use ruma::{
|
||||||
use crate::{service::rooms::timeline::PduId, PduEvent, Result};
|
use crate::{service::rooms::timeline::PduId, PduEvent, Result};
|
||||||
|
|
||||||
pub(crate) trait Data: Send + Sync {
|
pub(crate) trait Data: Send + Sync {
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
fn threads_until<'a>(
|
fn threads_until<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
user_id: &'a UserId,
|
user_id: &'a UserId,
|
||||||
|
|
|
||||||
|
|
@ -683,7 +683,7 @@ impl Service {
|
||||||
Ok(pdu_id)
|
Ok(pdu_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[expect(clippy::too_many_lines)]
|
||||||
pub(crate) fn create_hash_and_sign_event(
|
pub(crate) fn create_hash_and_sign_event(
|
||||||
&self,
|
&self,
|
||||||
pdu_builder: PduBuilder,
|
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
|
/// Returns an iterator over all events and their tokens in a room that
|
||||||
/// happened before the event with id `until` in reverse-chronological
|
/// happened before the event with id `until` in reverse-chronological
|
||||||
/// order.
|
/// order.
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
fn pdus_until<'a>(
|
fn pdus_until<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
user_id: &UserId,
|
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
|
/// Returns an iterator over all events in a room that happened after the
|
||||||
/// event with id `from` in chronological order.
|
/// event with id `from` in chronological order.
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
fn pdus_after<'a>(
|
fn pdus_after<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ use super::{Destination, RequestKey, SendingEventType};
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
|
|
||||||
pub(crate) trait Data: Send + Sync {
|
pub(crate) trait Data: Send + Sync {
|
||||||
#[allow(clippy::type_complexity)]
|
|
||||||
fn active_requests<'a>(
|
fn active_requests<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
) -> Box<
|
) -> Box<
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ pub(crate) struct SlidingSyncCache {
|
||||||
|
|
||||||
pub(crate) struct Service {
|
pub(crate) struct Service {
|
||||||
pub(crate) db: &'static dyn Data,
|
pub(crate) db: &'static dyn Data,
|
||||||
#[allow(clippy::type_complexity)]
|
#[expect(clippy::type_complexity)]
|
||||||
pub(crate) connections: Mutex<
|
pub(crate) connections: Mutex<
|
||||||
BTreeMap<
|
BTreeMap<
|
||||||
(OwnedUserId, OwnedDeviceId, String),
|
(OwnedUserId, OwnedDeviceId, String),
|
||||||
|
|
@ -58,7 +58,7 @@ impl Service {
|
||||||
self.connections.lock().unwrap().remove(&(user_id, device_id, conn_id));
|
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(
|
pub(crate) fn update_sync_request_with_cache(
|
||||||
&self,
|
&self,
|
||||||
user_id: OwnedUserId,
|
user_id: OwnedUserId,
|
||||||
|
|
@ -255,8 +255,10 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a user is an admin
|
/// Check if a user is an admin
|
||||||
// Allowed because this function uses `services()`
|
#[expect(
|
||||||
#[allow(clippy::unused_self)]
|
clippy::unused_self,
|
||||||
|
reason = "Allowed because this function uses `services()`"
|
||||||
|
)]
|
||||||
pub(crate) fn is_admin(&self, user_id: &UserId) -> Result<bool> {
|
pub(crate) fn is_admin(&self, user_id: &UserId) -> Result<bool> {
|
||||||
services().admin.get_admin_room()?.map_or(Ok(false), |admin_room_id| {
|
services().admin.get_admin_room()?.map_or(Ok(false), |admin_room_id| {
|
||||||
services().rooms.state_cache.is_joined(user_id, &admin_room_id)
|
services().rooms.state_cache.is_joined(user_id, &admin_room_id)
|
||||||
|
|
|
||||||
12
src/utils.rs
12
src/utils.rs
|
|
@ -21,8 +21,11 @@ use ruma::{
|
||||||
|
|
||||||
use crate::{Error, Result};
|
use crate::{Error, Result};
|
||||||
|
|
||||||
// Hopefully we have a better chat protocol in 530 years
|
#[expect(
|
||||||
#[allow(clippy::as_conversions, clippy::cast_possible_truncation)]
|
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 {
|
pub(crate) fn millis_since_unix_epoch() -> u64 {
|
||||||
SystemTime::now()
|
SystemTime::now()
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
|
|
@ -252,7 +255,10 @@ pub(crate) fn dbg_truncate_str(s: &str, mut max_len: usize) -> Cow<'_, str> {
|
||||||
if s.len() <= max_len {
|
if s.len() <= max_len {
|
||||||
s.into()
|
s.into()
|
||||||
} else {
|
} 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()
|
format!("{}...", &s[..max_len]).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,10 @@ use crate::Ra;
|
||||||
pub(crate) type Result<T, E = Error> = std::result::Result<T, E>;
|
pub(crate) type Result<T, E = Error> = std::result::Result<T, E>;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[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 {
|
pub(crate) enum Error {
|
||||||
#[cfg(feature = "sqlite")]
|
#[cfg(feature = "sqlite")]
|
||||||
#[error(
|
#[error(
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,11 @@ pub(crate) struct RoomVersion {
|
||||||
pub(crate) redaction_event_redacts_in_content: bool,
|
pub(crate) redaction_event_redacts_in_content: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allowed so that we can use struct-update syntax for incremental changes
|
#[expect(
|
||||||
// between versions even when all fields change.
|
clippy::needless_update,
|
||||||
#[allow(clippy::needless_update)]
|
reason = "so that we can use struct-update syntax for incremental changes \
|
||||||
|
between versions even when all fields change"
|
||||||
|
)]
|
||||||
mod known_versions {
|
mod known_versions {
|
||||||
use super::RoomVersion;
|
use super::RoomVersion;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue