Update style edition to 2024

This commit is contained in:
Lambda 2025-02-21 20:45:58 +00:00
parent 6e0152d4e5
commit a4355fe8aa
121 changed files with 367 additions and 335 deletions

View file

@ -1,4 +1,4 @@
style_edition = "2021" style_edition = "2024"
condense_wildcard_suffixes = true condense_wildcard_suffixes = true
error_on_line_overflow = true error_on_line_overflow = true

View file

@ -2,12 +2,12 @@ use std::{fmt::Debug, mem, time::Duration};
use bytes::BytesMut; use bytes::BytesMut;
use ruma::api::{ use ruma::api::{
appservice::Registration, IncomingResponse, MatrixVersion, OutgoingRequest, IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken,
SendAccessToken, appservice::Registration,
}; };
use tracing::warn; use tracing::warn;
use crate::{services, utils, Error, Result}; use crate::{Error, Result, services, utils};
/// Sends a request to an appservice /// Sends a request to an appservice
/// ///

View file

@ -1,25 +1,26 @@
use register::RegistrationKind; use register::RegistrationKind;
use ruma::{ use ruma::{
UserId,
api::client::{ api::client::{
account::{ account::{
change_password, deactivate, get_3pids, get_username_availability, ThirdPartyIdRemovalStatus, change_password, deactivate, get_3pids,
get_username_availability,
register::{self, LoginType}, register::{self, LoginType},
request_3pid_management_token_via_email, request_3pid_management_token_via_email,
request_3pid_management_token_via_msisdn, whoami, request_3pid_management_token_via_msisdn, whoami,
ThirdPartyIdRemovalStatus,
}, },
error::ErrorKind, error::ErrorKind,
uiaa::{AuthFlow, AuthType, UiaaInfo}, uiaa::{AuthFlow, AuthType, UiaaInfo},
}, },
events::{ events::{
room::message::RoomMessageEventContent, GlobalAccountDataEventType, GlobalAccountDataEventType, room::message::RoomMessageEventContent,
}, },
push, UserId, push,
}; };
use tracing::{info, warn}; use tracing::{info, warn};
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH}; use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
use crate::{api::client_server, services, utils, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, api::client_server, services, utils};
const RANDOM_USER_ID_LENGTH: usize = 10; const RANDOM_USER_ID_LENGTH: usize = 10;

View file

@ -1,5 +1,6 @@
use rand::seq::SliceRandom; use rand::seq::SliceRandom;
use ruma::{ use ruma::{
OwnedRoomAliasId,
api::{ api::{
appservice::query::query_room_alias, appservice::query::query_room_alias,
client::{ client::{
@ -8,10 +9,9 @@ use ruma::{
}, },
federation, federation,
}, },
OwnedRoomAliasId,
}; };
use crate::{services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services};
/// # `PUT /_matrix/client/r0/directory/room/{roomAlias}` /// # `PUT /_matrix/client/r0/directory/room/{roomAlias}`
/// ///

View file

@ -9,7 +9,7 @@ use ruma::api::client::{
error::ErrorKind, error::ErrorKind,
}; };
use crate::{services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services};
/// # `POST /_matrix/client/r0/room_keys/version` /// # `POST /_matrix/client/r0/room_keys/version`
/// ///

View file

@ -4,7 +4,7 @@ use ruma::api::client::discovery::get_capabilities::{
self, Capabilities, RoomVersionStability, RoomVersionsCapability, self, Capabilities, RoomVersionStability, RoomVersionsCapability,
}; };
use crate::{services, Ar, Ra, Result}; use crate::{Ar, Ra, Result, services};
/// # `GET /_matrix/client/r0/capabilities` /// # `GET /_matrix/client/r0/capabilities`
/// ///

View file

@ -14,7 +14,7 @@ use ruma::{
use serde::Deserialize; use serde::Deserialize;
use serde_json::{json, value::RawValue as RawJsonValue}; use serde_json::{json, value::RawValue as RawJsonValue};
use crate::{services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services};
/// # `PUT /_matrix/client/r0/user/{userId}/account_data/{type}` /// # `PUT /_matrix/client/r0/user/{userId}/account_data/{type}`
/// ///

View file

@ -9,7 +9,7 @@ use ruma::{
}; };
use tracing::error; use tracing::error;
use crate::{services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services};
/// # `GET /_matrix/client/r0/rooms/{roomId}/context` /// # `GET /_matrix/client/r0/rooms/{roomId}/context`
/// ///

View file

@ -8,7 +8,7 @@ use ruma::api::client::{
}; };
use super::SESSION_ID_LENGTH; use super::SESSION_ID_LENGTH;
use crate::{services, utils, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services, utils};
/// # `GET /_matrix/client/r0/devices` /// # `GET /_matrix/client/r0/devices`
/// ///

View file

@ -1,4 +1,5 @@
use ruma::{ use ruma::{
ServerName, UInt,
api::{ api::{
client::{ client::{
directory::{ directory::{
@ -12,6 +13,7 @@ use ruma::{
}, },
directory::{Filter, PublicRoomJoinRule, PublicRoomsChunk, RoomNetwork}, directory::{Filter, PublicRoomJoinRule, PublicRoomsChunk, RoomNetwork},
events::{ events::{
StateEventType,
room::{ room::{
avatar::RoomAvatarEventContent, avatar::RoomAvatarEventContent,
canonical_alias::RoomCanonicalAliasEventContent, canonical_alias::RoomCanonicalAliasEventContent,
@ -22,14 +24,13 @@ use ruma::{
join_rules::{JoinRule, RoomJoinRulesEventContent}, join_rules::{JoinRule, RoomJoinRulesEventContent},
topic::RoomTopicEventContent, topic::RoomTopicEventContent,
}, },
StateEventType,
}, },
uint, ServerName, UInt, uint,
}; };
use tracing::{error, info, warn}; use tracing::{error, info, warn};
use crate::{ use crate::{
service::rooms::state::ExtractType, services, Ar, Error, Ra, Result, Ar, Error, Ra, Result, service::rooms::state::ExtractType, services,
}; };
/// # `POST /_matrix/client/r0/publicRooms` /// # `POST /_matrix/client/r0/publicRooms`
@ -185,7 +186,7 @@ pub(crate) async fn get_public_rooms_filtered_helper(
return Err(Error::BadRequest( return Err(Error::BadRequest(
ErrorKind::InvalidParam, ErrorKind::InvalidParam,
"Invalid `since` token", "Invalid `since` token",
)) ));
} }
}; };

View file

@ -3,7 +3,7 @@ use ruma::api::client::{
filter::{create_filter, get_filter}, filter::{create_filter, get_filter},
}; };
use crate::{services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services};
/// # `GET /_matrix/client/r0/user/{userId}/filter/{filterId}` /// # `GET /_matrix/client/r0/user/{userId}/filter/{filterId}`
/// ///

View file

@ -1,10 +1,12 @@
use std::{ use std::{
collections::{hash_map, BTreeMap, HashMap, HashSet}, collections::{BTreeMap, HashMap, HashSet, hash_map},
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use futures_util::{stream::FuturesUnordered, StreamExt}; use futures_util::{StreamExt, stream::FuturesUnordered};
use ruma::{ use ruma::{
OneTimeKeyAlgorithm, OwnedDeviceId, OwnedServerName, OwnedUserId,
ServerName, UserId,
api::{ api::{
client::{ client::{
error::ErrorKind, error::ErrorKind,
@ -17,14 +19,12 @@ use ruma::{
federation, federation,
}, },
serde::Raw, serde::Raw,
OneTimeKeyAlgorithm, OwnedDeviceId, OwnedServerName, OwnedUserId,
ServerName, UserId,
}; };
use serde_json::json; use serde_json::json;
use tracing::debug; use tracing::debug;
use super::SESSION_ID_LENGTH; use super::SESSION_ID_LENGTH;
use crate::{services, utils, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services, utils};
/// # `POST /_matrix/client/r0/keys/upload` /// # `POST /_matrix/client/r0/keys/upload`
/// ///

View file

@ -2,10 +2,10 @@ use std::time::Duration;
use axum::response::IntoResponse; use axum::response::IntoResponse;
use http::{ use http::{
header::{CONTENT_DISPOSITION, CONTENT_SECURITY_POLICY, CONTENT_TYPE},
HeaderName, HeaderValue, Method, HeaderName, HeaderValue, Method,
header::{CONTENT_DISPOSITION, CONTENT_SECURITY_POLICY, CONTENT_TYPE},
}; };
use phf::{phf_set, Set}; use phf::{Set, phf_set};
use ruma::{ use ruma::{
api::{ api::{
client::{ client::{
@ -20,10 +20,10 @@ use ruma::{
use tracing::{debug, error, info, warn}; use tracing::{debug, error, info, warn};
use crate::{ use crate::{
Ar, Error, Ra, Result,
service::media::FileMeta, service::media::FileMeta,
services, services,
utils::{self, MxcData}, utils::{self, MxcData},
Ar, Error, Ra, Result,
}; };
const MXC_LENGTH: usize = 32; const MXC_LENGTH: usize = 32;

View file

@ -1,46 +1,48 @@
use std::{ use std::{
collections::{hash_map::Entry, BTreeMap, HashMap, HashSet}, collections::{BTreeMap, HashMap, HashSet, hash_map::Entry},
sync::Arc, sync::Arc,
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use ruma::{ use ruma::{
CanonicalJsonObject, CanonicalJsonValue, EventId,
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName,
OwnedUserId, RoomId, RoomVersionId, UserId,
api::{ api::{
client::{ client::{
error::ErrorKind, error::ErrorKind,
membership::{ membership::{
ban_user, forget_room, get_member_events, invite_user, ThirdPartySigned, ban_user, forget_room, get_member_events,
join_room_by_id, join_room_by_id_or_alias, joined_members, invite_user, join_room_by_id, join_room_by_id_or_alias,
joined_rooms, kick_user, leave_room, unban_user, joined_members, joined_rooms, kick_user, leave_room,
ThirdPartySigned, unban_user,
}, },
}, },
federation::{self, membership::create_invite}, federation::{self, membership::create_invite},
}, },
canonical_json::to_canonical_value, canonical_json::to_canonical_value,
events::{ events::{
StateEventType, TimelineEventType,
room::{ room::{
join_rules::{AllowRule, JoinRule, RoomJoinRulesEventContent}, join_rules::{AllowRule, JoinRule, RoomJoinRulesEventContent},
member::{MembershipState, RoomMemberEventContent}, member::{MembershipState, RoomMemberEventContent},
}, },
StateEventType, TimelineEventType,
}, },
state_res, CanonicalJsonObject, CanonicalJsonValue, EventId, state_res,
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName,
OwnedUserId, RoomId, RoomVersionId, UserId,
}; };
use serde_json::value::{to_raw_value, RawValue as RawJsonValue}; use serde_json::value::{RawValue as RawJsonValue, to_raw_value};
use tokio::sync::RwLock; use tokio::sync::RwLock;
use tracing::{debug, error, info, warn}; use tracing::{debug, error, info, warn};
use super::get_alias_helper; use super::get_alias_helper;
use crate::{ use crate::{
Ar, Error, PduEvent, Ra, Result,
service::{ service::{
globals::SigningKeys, globals::SigningKeys,
pdu::{gen_event_id_canonical_json, PduBuilder}, pdu::{PduBuilder, gen_event_id_canonical_json},
rooms::state::ExtractVersion, rooms::state::ExtractVersion,
}, },
services, utils, Ar, Error, PduEvent, Ra, Result, services, utils,
}; };
/// # `POST /_matrix/client/r0/rooms/{roomId}/join` /// # `POST /_matrix/client/r0/rooms/{roomId}/join`
@ -625,7 +627,7 @@ async fn join_room_by_id_helper(
Ok(_event_id) => { Ok(_event_id) => {
return Ok(join_room_by_id::v3::Response::new( return Ok(join_room_by_id::v3::Response::new(
room_id.to_owned(), room_id.to_owned(),
)) ));
} }
Err(e) => e, Err(e) => e,
}; };
@ -658,7 +660,7 @@ async fn join_room_by_id_helper(
_ => { _ => {
return Err(Error::BadServerResponse( return Err(Error::BadServerResponse(
"Room version is not supported", "Room version is not supported",
)) ));
} }
}; };
let mut join_event_stub: CanonicalJsonObject = serde_json::from_str( let mut join_event_stub: CanonicalJsonObject = serde_json::from_str(
@ -810,7 +812,7 @@ async fn join_room_by_id_helper(
_ => { _ => {
return Err(Error::BadServerResponse( return Err(Error::BadServerResponse(
"Room version is not supported", "Room version is not supported",
)) ));
} }
}; };
@ -1638,7 +1640,7 @@ async fn remote_leave_room(user_id: &UserId, room_id: &RoomId) -> Result<()> {
_ => { _ => {
return Err(Error::BadServerResponse( return Err(Error::BadServerResponse(
"Room version is not supported", "Room version is not supported",
)) ));
} }
}; };

View file

@ -10,8 +10,9 @@ use ruma::{
}; };
use crate::{ use crate::{
Ar, Error, Ra, Result,
service::{pdu::PduBuilder, rooms::timeline::PduCount}, service::{pdu::PduBuilder, rooms::timeline::PduCount},
services, utils, Ar, Error, Ra, Result, services, utils,
}; };
/// # `PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}` /// # `PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}`

View file

@ -10,13 +10,13 @@ use ruma::{
federation::{self, query::get_profile_information::v1::ProfileField}, federation::{self, query::get_profile_information::v1::ProfileField},
}, },
events::{ events::{
room::member::RoomMemberEventContent, StateEventType, TimelineEventType, StateEventType, TimelineEventType, room::member::RoomMemberEventContent,
}, },
}; };
use serde_json::value::to_raw_value; use serde_json::value::to_raw_value;
use tracing::warn; use tracing::warn;
use crate::{service::pdu::PduBuilder, services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, service::pdu::PduBuilder, services};
/// # `PUT /_matrix/client/r0/profile/{userId}/displayname` /// # `PUT /_matrix/client/r0/profile/{userId}/displayname`
/// ///

View file

@ -7,11 +7,11 @@ use ruma::{
set_pushrule_actions, set_pushrule_enabled, set_pushrule_actions, set_pushrule_enabled,
}, },
}, },
events::{push_rules::PushRulesEvent, GlobalAccountDataEventType}, events::{GlobalAccountDataEventType, push_rules::PushRulesEvent},
push::{AnyPushRuleRef, InsertPushRuleError, RemovePushRuleError}, push::{AnyPushRuleRef, InsertPushRuleError, RemovePushRuleError},
}; };
use crate::{services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services};
/// # `GET /_matrix/client/r0/pushrules` /// # `GET /_matrix/client/r0/pushrules`
/// ///

View file

@ -1,18 +1,18 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma::{ use ruma::{
MilliSecondsSinceUnixEpoch,
api::client::{ api::client::{
error::ErrorKind, read_marker::set_read_marker, receipt::create_receipt, error::ErrorKind, read_marker::set_read_marker, receipt::create_receipt,
}, },
events::{ events::{
receipt::{ReceiptThread, ReceiptType},
RoomAccountDataEventType, RoomAccountDataEventType,
receipt::{ReceiptThread, ReceiptType},
}, },
MilliSecondsSinceUnixEpoch,
}; };
use crate::{ use crate::{
service::rooms::timeline::PduCount, services, Ar, Error, Ra, Result, Ar, Error, Ra, Result, service::rooms::timeline::PduCount, services,
}; };
/// # `POST /_matrix/client/r0/rooms/{roomId}/read_markers` /// # `POST /_matrix/client/r0/rooms/{roomId}/read_markers`
@ -58,7 +58,7 @@ pub(crate) async fn set_read_marker_route(
return Err(Error::BadRequest( return Err(Error::BadRequest(
ErrorKind::InvalidParam, ErrorKind::InvalidParam,
"Read receipt is in backfilled timeline", "Read receipt is in backfilled timeline",
)) ));
} }
PduCount::Normal(c) => c, PduCount::Normal(c) => c,
}; };
@ -174,7 +174,7 @@ pub(crate) async fn create_receipt_route(
return Err(Error::BadRequest( return Err(Error::BadRequest(
ErrorKind::InvalidParam, ErrorKind::InvalidParam,
"Read receipt is in backfilled timeline", "Read receipt is in backfilled timeline",
)) ));
} }
PduCount::Normal(c) => c, PduCount::Normal(c) => c,
}; };

View file

@ -1,10 +1,10 @@
use ruma::{ use ruma::{
api::client::redact::redact_event, api::client::redact::redact_event,
events::{room::redaction::RoomRedactionEventContent, TimelineEventType}, events::{TimelineEventType, room::redaction::RoomRedactionEventContent},
}; };
use serde_json::value::to_raw_value; use serde_json::value::to_raw_value;
use crate::{service::pdu::PduBuilder, services, Ar, Ra, Result}; use crate::{Ar, Ra, Result, service::pdu::PduBuilder, services};
/// # `PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}` /// # `PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}`
/// ///

View file

@ -6,7 +6,7 @@ use ruma::{
uint, uint,
}; };
use crate::{service::rooms::timeline::PduCount, services, Ar, Ra, Result}; use crate::{Ar, Ra, Result, service::rooms::timeline::PduCount, services};
/// # `GET /_matrix/client/r0/rooms/{roomId}/relations/{eventId}/{relType}/{eventType}` /// # `GET /_matrix/client/r0/rooms/{roomId}/relations/{eventId}/{relType}/{eventType}`
pub(crate) async fn get_relating_events_with_rel_type_and_event_type_route( pub(crate) async fn get_relating_events_with_rel_type_and_event_type_route(

View file

@ -4,7 +4,7 @@ use ruma::{
int, int,
}; };
use crate::{services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services};
/// # `POST /_matrix/client/r0/rooms/{roomId}/report/{eventId}` /// # `POST /_matrix/client/r0/rooms/{roomId}/report/{eventId}`
/// ///

View file

@ -1,11 +1,13 @@
use std::{cmp::max, collections::BTreeMap}; use std::{cmp::max, collections::BTreeMap};
use ruma::{ use ruma::{
CanonicalJsonObject, OwnedRoomAliasId, RoomAliasId, RoomId,
api::client::{ api::client::{
error::ErrorKind, error::ErrorKind,
room::{self, aliases, create_room, get_room_event, upgrade_room}, room::{self, aliases, create_room, get_room_event, upgrade_room},
}, },
events::{ events::{
StateEventType, TimelineEventType,
room::{ room::{
canonical_alias::RoomCanonicalAliasEventContent, canonical_alias::RoomCanonicalAliasEventContent,
create::RoomCreateEventContent, create::RoomCreateEventContent,
@ -20,18 +22,16 @@ use ruma::{
tombstone::RoomTombstoneEventContent, tombstone::RoomTombstoneEventContent,
topic::RoomTopicEventContent, topic::RoomTopicEventContent,
}, },
StateEventType, TimelineEventType,
}, },
int, int,
serde::JsonObject, serde::JsonObject,
CanonicalJsonObject, OwnedRoomAliasId, RoomAliasId, RoomId,
}; };
use serde_json::{json, value::to_raw_value}; use serde_json::{json, value::to_raw_value};
use tracing::{info, warn}; use tracing::{info, warn};
use crate::{ use crate::{
api::client_server::invite_helper, service::pdu::PduBuilder, services, Ar, Error, Ra, Result, api::client_server::invite_helper,
utils::room_version::RoomVersion, Ar, Error, Ra, Result, service::pdu::PduBuilder, services, utils::room_version::RoomVersion,
}; };
/// # `POST /_matrix/client/r0/createRoom` /// # `POST /_matrix/client/r0/createRoom`

View file

@ -1,6 +1,7 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma::{ use ruma::{
UInt,
api::client::{ api::client::{
error::ErrorKind, error::ErrorKind,
search::search_events::{ search::search_events::{
@ -11,10 +12,10 @@ use ruma::{
}, },
}, },
}, },
uint, UInt, uint,
}; };
use crate::{services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services};
/// # `POST /_matrix/client/r0/search` /// # `POST /_matrix/client/r0/search`
/// ///
@ -73,7 +74,7 @@ pub(crate) async fn search_events_route(
return Err(Error::BadRequest( return Err(Error::BadRequest(
ErrorKind::InvalidParam, ErrorKind::InvalidParam,
"Invalid next_batch token.", "Invalid next_batch token.",
)) ));
} }
// Default to the start // Default to the start
None => 0, None => 0,

View file

@ -1,4 +1,5 @@
use ruma::{ use ruma::{
UserId,
api::client::{ api::client::{
error::ErrorKind, error::ErrorKind,
session::{ session::{
@ -10,13 +11,12 @@ use ruma::{
}, },
uiaa::UserIdentifier, uiaa::UserIdentifier,
}, },
UserId,
}; };
use serde::Deserialize; use serde::Deserialize;
use tracing::{info, warn}; use tracing::{info, warn};
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH}; use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
use crate::{services, utils, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services, utils};
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
struct Claims { struct Claims {

View file

@ -1,6 +1,6 @@
use ruma::{api::client::space::get_hierarchy, uint}; use ruma::{api::client::space::get_hierarchy, uint};
use crate::{services, Ar, Ra, Result}; use crate::{Ar, Ra, Result, services};
/// # `GET /_matrix/client/v1/rooms/{room_id}/hierarchy` /// # `GET /_matrix/client/v1/rooms/{room_id}/hierarchy`
/// ///

View file

@ -1,21 +1,21 @@
use std::{collections::HashSet, sync::Arc}; use std::{collections::HashSet, sync::Arc};
use ruma::{ use ruma::{
EventId, RoomAliasId, RoomId, UserId,
api::client::{ api::client::{
error::ErrorKind, error::ErrorKind,
state::{get_state_events, get_state_events_for_key, send_state_event}, state::{get_state_events, get_state_events_for_key, send_state_event},
}, },
events::{ events::{
room::canonical_alias::RoomCanonicalAliasEventContent,
AnyStateEventContent, StateEventType, AnyStateEventContent, StateEventType,
room::canonical_alias::RoomCanonicalAliasEventContent,
}, },
serde::Raw, serde::Raw,
EventId, RoomAliasId, RoomId, UserId,
}; };
use serde::Deserialize; use serde::Deserialize;
use tracing::warn; use tracing::warn;
use crate::{service::pdu::PduBuilder, services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, service::pdu::PduBuilder, services};
/// # `PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}` /// # `PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}`
/// ///

View file

@ -1,8 +1,8 @@
use ruma::{events::StateEventType, RoomId, UserId}; use ruma::{RoomId, UserId, events::StateEventType};
use tracing::error; use tracing::error;
use crate::{ use crate::{
service::rooms::timeline::PduCount, services, Error, PduEvent, Result, Error, PduEvent, Result, service::rooms::timeline::PduCount, services,
}; };
pub(crate) mod msc3575; pub(crate) mod msc3575;

View file

@ -9,23 +9,24 @@ use std::{
}; };
use ruma::{ use ruma::{
JsOption, UInt, UserId,
api::client::{ api::client::{
sync::sync_events::{ sync::sync_events::{
self, v4::SlidingOp, DeviceLists, UnreadNotificationsCount, self, DeviceLists, UnreadNotificationsCount, v4::SlidingOp,
}, },
uiaa::UiaaResponse, uiaa::UiaaResponse,
}, },
events::{ events::{
room::member::{MembershipState, RoomMemberEventContent},
StateEventType, TimelineEventType, StateEventType, TimelineEventType,
room::member::{MembershipState, RoomMemberEventContent},
}, },
uint, JsOption, UInt, UserId, uint,
}; };
use tracing::{debug, error}; use tracing::{debug, error};
use super::{load_timeline, share_encrypted_room}; use super::{load_timeline, share_encrypted_room};
use crate::{ use crate::{
service::rooms::timeline::PduCount, services, Ar, Error, Ra, Result, Ar, Error, Ra, Result, service::rooms::timeline::PduCount, services,
}; };
#[allow(clippy::too_many_lines)] #[allow(clippy::too_many_lines)]

View file

@ -4,31 +4,32 @@ use std::{
}; };
use ruma::{ use ruma::{
DeviceId, EventId, OwnedRoomId, OwnedUserId, RoomId, UInt, UserId,
api::client::{ api::client::{
filter::{FilterDefinition, LazyLoadOptions}, filter::{FilterDefinition, LazyLoadOptions},
sync::sync_events::{ sync::sync_events::{
self, self, DeviceLists, UnreadNotificationsCount,
v3::{ v3::{
Ephemeral, Filter, GlobalAccountData, InviteState, InvitedRoom, Ephemeral, Filter, GlobalAccountData, InviteState, InvitedRoom,
JoinedRoom, LeftRoom, Presence, RoomAccountData, RoomSummary, JoinedRoom, LeftRoom, Presence, RoomAccountData, RoomSummary,
Rooms, State, Timeline, ToDevice, Rooms, State, Timeline, ToDevice,
}, },
DeviceLists, UnreadNotificationsCount,
}, },
uiaa::UiaaResponse, uiaa::UiaaResponse,
}, },
events::{ events::{
room::member::{MembershipState, RoomMemberEventContent},
StateEventType, TimelineEventType, StateEventType, TimelineEventType,
room::member::{MembershipState, RoomMemberEventContent},
}, },
uint, DeviceId, EventId, OwnedRoomId, OwnedUserId, RoomId, UInt, UserId, uint,
}; };
use tracing::{debug, error, field}; use tracing::{debug, error, field};
use super::{load_timeline, share_encrypted_room}; use super::{load_timeline, share_encrypted_room};
use crate::{ use crate::{
Ar, Error, PduEvent, Ra, Result,
service::{pdu::EventHash, rooms::timeline::PduCount}, service::{pdu::EventHash, rooms::timeline::PduCount},
services, utils, Ar, Error, PduEvent, Ra, Result, services, utils,
}; };
struct SyncContext<'a> { struct SyncContext<'a> {

View file

@ -3,12 +3,12 @@ use std::collections::BTreeMap;
use ruma::{ use ruma::{
api::client::tag::{create_tag, delete_tag, get_tags}, api::client::tag::{create_tag, delete_tag, get_tags},
events::{ events::{
tag::{TagEvent, TagEventContent},
RoomAccountDataEventType, RoomAccountDataEventType,
tag::{TagEvent, TagEventContent},
}, },
}; };
use crate::{services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services};
/// # `PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}` /// # `PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}`
/// ///

View file

@ -1,6 +1,6 @@
use ruma::api::client::{error::ErrorKind, threads::get_threads}; use ruma::api::client::{error::ErrorKind, threads::get_threads};
use crate::{services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services};
/// # `GET /_matrix/client/r0/rooms/{roomId}/threads` /// # `GET /_matrix/client/r0/rooms/{roomId}/threads`
pub(crate) async fn get_threads_route( pub(crate) async fn get_threads_route(

View file

@ -9,7 +9,7 @@ use ruma::{
to_device::DeviceIdOrAllDevices, to_device::DeviceIdOrAllDevices,
}; };
use crate::{services, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services};
/// # `PUT /_matrix/client/r0/sendToDevice/{eventType}/{txnId}` /// # `PUT /_matrix/client/r0/sendToDevice/{eventType}/{txnId}`
/// ///

View file

@ -1,6 +1,6 @@
use ruma::api::client::{error::ErrorKind, typing::create_typing_event}; use ruma::api::client::{error::ErrorKind, typing::create_typing_event};
use crate::{services, utils, Ar, Error, Ra, Result}; use crate::{Ar, Error, Ra, Result, services, utils};
/// # `PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}` /// # `PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}`
/// ///

View file

@ -1,12 +1,12 @@
use ruma::{ use ruma::{
api::client::user_directory::search_users, api::client::user_directory::search_users,
events::{ events::{
room::join_rules::{JoinRule, RoomJoinRulesEventContent},
StateEventType, StateEventType,
room::join_rules::{JoinRule, RoomJoinRulesEventContent},
}, },
}; };
use crate::{services, Ar, Ra, Result}; use crate::{Ar, Ra, Result, services};
/// # `POST /_matrix/client/r0/user_directory/search` /// # `POST /_matrix/client/r0/user_directory/search`
/// ///

View file

@ -1,11 +1,11 @@
use std::time::{Duration, SystemTime}; use std::time::{Duration, SystemTime};
use base64::{engine::general_purpose, Engine as _}; use base64::{Engine as _, engine::general_purpose};
use hmac::{Hmac, Mac}; use hmac::{Hmac, Mac};
use ruma::{api::client::voip::get_turn_server_info, SecondsSinceUnixEpoch}; use ruma::{SecondsSinceUnixEpoch, api::client::voip::get_turn_server_info};
use sha1::Sha1; use sha1::Sha1;
use crate::{services, Ar, Ra, Result}; use crate::{Ar, Ra, Result, services};
type HmacSha1 = Hmac<Sha1>; type HmacSha1 = Hmac<Sha1>;

View file

@ -1,11 +1,11 @@
use std::ops::Deref; use std::ops::Deref;
use ruma::{ use ruma::{
api::client::uiaa::UiaaResponse, CanonicalJsonValue, OwnedDeviceId, CanonicalJsonValue, OwnedDeviceId, OwnedServerName, OwnedUserId,
OwnedServerName, OwnedUserId, api::client::uiaa::UiaaResponse,
}; };
use crate::{service::appservice::RegistrationInfo, Error}; use crate::{Error, service::appservice::RegistrationInfo};
mod axum; mod axum;

View file

@ -1,34 +1,33 @@
use std::{collections::BTreeMap, iter::FromIterator, str}; use std::{collections::BTreeMap, iter::FromIterator, str};
use axum::{ use axum::{
async_trait, RequestExt, RequestPartsExt, async_trait,
body::Body, body::Body,
extract::{FromRequest, Path}, extract::{FromRequest, Path},
response::{IntoResponse, Response}, response::{IntoResponse, Response},
RequestExt, RequestPartsExt,
}; };
use axum_extra::{ use axum_extra::{
headers::{authorization::Bearer, Authorization},
typed_header::TypedHeaderRejectionReason,
TypedHeader, TypedHeader,
headers::{Authorization, authorization::Bearer},
typed_header::TypedHeaderRejectionReason,
}; };
use bytes::{BufMut, Bytes, BytesMut}; use bytes::{BufMut, Bytes, BytesMut};
use http::{Request, StatusCode}; use http::{Request, StatusCode};
use http_body_util::BodyExt; use http_body_util::BodyExt;
use ruma::{ use ruma::{
api::{
client::error::ErrorKind, AuthScheme, IncomingRequest, Metadata,
OutgoingResponse,
},
server_util::authorization::XMatrix,
CanonicalJsonValue, MilliSecondsSinceUnixEpoch, OwnedDeviceId, CanonicalJsonValue, MilliSecondsSinceUnixEpoch, OwnedDeviceId,
OwnedServerName, OwnedUserId, UserId, OwnedServerName, OwnedUserId, UserId,
api::{
AuthScheme, IncomingRequest, Metadata, OutgoingResponse,
client::error::ErrorKind,
},
server_util::authorization::XMatrix,
}; };
use serde::Deserialize; use serde::Deserialize;
use tracing::{error, warn}; use tracing::{error, warn};
use super::{Ar, Ra}; use super::{Ar, Ra};
use crate::{service::appservice::RegistrationInfo, services, Error, Result}; use crate::{Error, Result, service::appservice::RegistrationInfo, services};
enum Token { enum Token {
Appservice(Box<RegistrationInfo>), Appservice(Box<RegistrationInfo>),
@ -122,7 +121,7 @@ async fn ar_from_request_inner(
soft_logout: false, soft_logout: false,
}, },
"Unknown access token.", "Unknown access token.",
)) ));
} }
(AuthScheme::AccessToken, Token::Appservice(info)) => { (AuthScheme::AccessToken, Token::Appservice(info)) => {
let user_id = query_params let user_id = query_params

View file

@ -7,12 +7,18 @@ use std::{
time::Instant, time::Instant,
}; };
use axum::{response::IntoResponse, Json}; use axum::{Json, response::IntoResponse};
use axum_extra::headers::{Authorization, HeaderMapExt}; use axum_extra::headers::{Authorization, HeaderMapExt};
use base64::Engine as _; use base64::Engine as _;
use get_profile_information::v1::ProfileField; use get_profile_information::v1::ProfileField;
use ruma::{ use ruma::{
CanonicalJsonObject, CanonicalJsonValue, EventId,
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName,
OwnedServerSigningKeyId, OwnedSigningKeyId, OwnedUserId, RoomId,
ServerName, Signatures,
api::{ api::{
EndpointError, IncomingResponse, MatrixVersion, OutgoingRequest,
OutgoingResponse, SendAccessToken,
client::error::{Error as RumaError, ErrorKind}, client::error::{Error as RumaError, ErrorKind},
federation::{ federation::{
authenticated_media, authenticated_media,
@ -21,7 +27,7 @@ use ruma::{
device::get_devices::{self, v1::UserDevice}, device::get_devices::{self, v1::UserDevice},
directory::{get_public_rooms, get_public_rooms_filtered}, directory::{get_public_rooms, get_public_rooms_filtered},
discovery::{ discovery::{
get_server_keys, get_server_version, ServerSigningKeys, ServerSigningKeys, get_server_keys, get_server_version,
}, },
event::{ event::{
get_event, get_missing_events, get_room_state, get_event, get_missing_events, get_room_state,
@ -40,43 +46,38 @@ use ruma::{
send_transaction_message, send_transaction_message,
}, },
}, },
EndpointError, IncomingResponse, MatrixVersion, OutgoingRequest,
OutgoingResponse, SendAccessToken,
}, },
directory::{Filter, RoomNetwork}, directory::{Filter, RoomNetwork},
events::{ events::{
StateEventType, TimelineEventType,
receipt::{ReceiptEvent, ReceiptEventContent, ReceiptType}, receipt::{ReceiptEvent, ReceiptEventContent, ReceiptType},
room::{ room::{
join_rules::{JoinRule, RoomJoinRulesEventContent}, join_rules::{JoinRule, RoomJoinRulesEventContent},
member::{MembershipState, RoomMemberEventContent}, member::{MembershipState, RoomMemberEventContent},
}, },
StateEventType, TimelineEventType,
}, },
serde::{Base64, JsonObject, Raw}, serde::{Base64, JsonObject, Raw},
server_util::authorization::XMatrix, server_util::authorization::XMatrix,
state_res::Event, state_res::Event,
to_device::DeviceIdOrAllDevices, to_device::DeviceIdOrAllDevices,
uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId, uint, user_id,
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName,
OwnedServerSigningKeyId, OwnedSigningKeyId, OwnedUserId, RoomId,
ServerName, Signatures,
}; };
use serde_json::value::{to_raw_value, RawValue as RawJsonValue}; use serde_json::value::{RawValue as RawJsonValue, to_raw_value};
use tokio::sync::RwLock; use tokio::sync::RwLock;
use tracing::{debug, error, field, trace, trace_span, warn}; use tracing::{debug, error, field, trace, trace_span, warn};
use super::appservice_server; use super::appservice_server;
use crate::{ use crate::{
Ar, Error, PduEvent, Ra, Result,
api::client_server::{self, claim_keys_helper, get_keys_helper}, api::client_server::{self, claim_keys_helper, get_keys_helper},
observability::{FoundIn, Lookup, METRICS}, observability::{FoundIn, Lookup, METRICS},
service::{ service::{
globals::SigningKeys, globals::SigningKeys,
pdu::{gen_event_id_canonical_json, PduBuilder}, pdu::{PduBuilder, gen_event_id_canonical_json},
rooms::state::ExtractVersion, rooms::state::ExtractVersion,
}, },
services, services,
utils::{self, dbg_truncate_str, MxcData}, utils::{self, MxcData, dbg_truncate_str},
Ar, Error, PduEvent, Ra, Result,
}; };
/// Wraps either an literal IP address plus port, or a hostname plus complement /// Wraps either an literal IP address plus port, or a hostname plus complement
@ -2158,7 +2159,7 @@ pub(crate) async fn media_thumbnail_route(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{add_port_to_hostname, get_ip_with_port, FedDest}; use super::{FedDest, add_port_to_hostname, get_ip_with_port};
#[test] #[test]
fn ips_get_default_ports() { fn ips_get_default_ports() {

View file

@ -8,7 +8,7 @@ use ruma::api::{
federation::discovery::discover_homeserver as server, federation::discovery::discover_homeserver as server,
}; };
use crate::{services, Ar, Ra}; use crate::{Ar, Ra, services};
/// Handler for `/.well-known/matrix/server` /// Handler for `/.well-known/matrix/server`
pub(crate) async fn server( pub(crate) async fn server(

View file

@ -8,7 +8,7 @@ use std::path::PathBuf;
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
use crate::{ use crate::{
config::{default_tracing_filter, EnvFilterClone, LogFormat}, config::{EnvFilterClone, LogFormat, default_tracing_filter},
error, observability, error, observability,
}; };

View file

@ -4,35 +4,35 @@ use std::{
}; };
use axum::{ use axum::{
Router,
extract::{ extract::{
connect_info::IntoMakeServiceWithConnectInfo, ConnectInfo, ConnectInfo, DefaultBodyLimit, FromRequestParts, MatchedPath,
DefaultBodyLimit, FromRequestParts, MatchedPath, connect_info::IntoMakeServiceWithConnectInfo,
}, },
middleware::AddExtension, middleware::AddExtension,
response::IntoResponse, response::IntoResponse,
routing::{any, get, on, MethodFilter, Route}, routing::{MethodFilter, Route, any, get, on},
Router,
}; };
use axum_server::{ use axum_server::{
Handle as ServerHandle, Server,
accept::Accept, accept::Accept,
bind, bind,
service::SendService, service::SendService,
tls_rustls::{RustlsAcceptor, RustlsConfig}, tls_rustls::{RustlsAcceptor, RustlsConfig},
Handle as ServerHandle, Server,
}; };
use http::{ use http::{
header::{self, HeaderName},
Method, StatusCode, Uri, Method, StatusCode, Uri,
header::{self, HeaderName},
}; };
use hyper::body::Incoming; use hyper::body::Incoming;
use proxy_header::ProxyHeader; use proxy_header::ProxyHeader;
use ruma::api::{ use ruma::api::{
IncomingRequest,
client::{ client::{
error::{Error as RumaError, ErrorBody, ErrorKind}, error::{Error as RumaError, ErrorBody, ErrorKind},
uiaa::UiaaResponse, uiaa::UiaaResponse,
}, },
federation::discovery::get_server_version, federation::discovery::get_server_version,
IncomingRequest,
}; };
use tokio::{ use tokio::{
io::{AsyncRead, AsyncWrite}, io::{AsyncRead, AsyncWrite},
@ -42,14 +42,15 @@ use tokio::{
}; };
use tower::{Layer, Service, ServiceBuilder}; use tower::{Layer, Service, ServiceBuilder};
use tower_http::{ use tower_http::{
ServiceBuilderExt as _,
cors::{self, CorsLayer}, cors::{self, CorsLayer},
trace::TraceLayer, trace::TraceLayer,
ServiceBuilderExt as _,
}; };
use tracing::{debug, info, info_span, warn, Instrument}; use tracing::{Instrument, debug, info, info_span, warn};
use super::ServeArgs; use super::ServeArgs;
use crate::{ use crate::{
ApplicationState, Services,
api::{ api::{
client_server, client_server,
ruma_wrapper::{Ar, Ra}, ruma_wrapper::{Ar, Ra},
@ -64,7 +65,6 @@ use crate::{
error::{Error, Result}, error::{Error, Result},
proxy_protocol::{ProxyAcceptor, ProxyAcceptorConfig}, proxy_protocol::{ProxyAcceptor, ProxyAcceptorConfig},
}, },
ApplicationState, Services,
}; };
pub(crate) async fn run(args: ServeArgs) -> Result<(), error::ServeCommand> { pub(crate) async fn run(args: ServeArgs) -> Result<(), error::ServeCommand> {

View file

@ -9,8 +9,8 @@ use std::{
use reqwest::Url; use reqwest::Url;
use ruma::{ use ruma::{
api::federation::discovery::OldVerifyKey, OwnedServerName, OwnedServerName, OwnedServerSigningKeyId, RoomVersionId, UInt,
OwnedServerSigningKeyId, RoomVersionId, UInt, api::federation::discovery::OldVerifyKey,
}; };
use serde::Deserialize; use serde::Deserialize;
use strum::{Display, EnumIter, IntoEnumIterator}; use strum::{Display, EnumIter, IntoEnumIterator};
@ -415,7 +415,7 @@ impl Default for FederationConfig {
enable: true, enable: true,
self_test: true, self_test: true,
trusted_servers: vec![ trusted_servers: vec![
OwnedServerName::try_from("matrix.org").unwrap() OwnedServerName::try_from("matrix.org").unwrap(),
], ],
max_fetch_prev_events: 100, max_fetch_prev_events: 100,
max_concurrent_requests: 100, max_concurrent_requests: 100,

View file

@ -7,7 +7,7 @@
use std::{fmt, str::FromStr}; use std::{fmt, str::FromStr};
use serde::{de, Deserialize, Deserializer}; use serde::{Deserialize, Deserializer, de};
use tracing_subscriber::EnvFilter; use tracing_subscriber::EnvFilter;
/// A workaround for [`EnvFilter`] not directly implementing [`Clone`] /// A workaround for [`EnvFilter`] not directly implementing [`Clone`]

View file

@ -8,13 +8,14 @@ use std::{
}; };
use ruma::{ use ruma::{
events::{push_rules::PushRulesEvent, GlobalAccountDataEventType},
push::Ruleset,
EventId, OwnedRoomId, RoomId, UserId, EventId, OwnedRoomId, RoomId, UserId,
events::{GlobalAccountDataEventType, push_rules::PushRulesEvent},
push::Ruleset,
}; };
use tracing::{debug, error, info, info_span, warn, Instrument}; use tracing::{Instrument, debug, error, info, info_span, warn};
use crate::{ use crate::{
Config, Error, Result,
config::DatabaseBackend, config::DatabaseBackend,
service::{ service::{
media::MediaFileKey, media::MediaFileKey,
@ -23,7 +24,7 @@ use crate::{
state_compressor::CompressedStateEvent, state_compressor::CompressedStateEvent,
}, },
}, },
services, utils, Config, Error, Result, services, utils,
}; };
pub(crate) mod abstraction; pub(crate) mod abstraction;
@ -1031,7 +1032,7 @@ impl KeyValueDatabase {
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
#[cfg(unix)] #[cfg(unix)]
use tokio::signal::unix::{signal, SignalKind}; use tokio::signal::unix::{SignalKind, signal};
use tokio::time::interval; use tokio::time::interval;
let timer_interval = Duration::from_secs(u64::from( let timer_interval = Duration::from_secs(u64::from(

View file

@ -13,9 +13,9 @@ use rocksdb::{
use tracing::Level; use tracing::Level;
use super::{ use super::{
super::Config, watchers::Watchers, KeyValueDatabaseEngine, KvTree, super::Config, KeyValueDatabaseEngine, KvTree, watchers::Watchers,
}; };
use crate::{utils, Result}; use crate::{Result, utils};
pub(crate) struct Engine { pub(crate) struct Engine {
rocks: DBWithThreadMode<MultiThreaded>, rocks: DBWithThreadMode<MultiThreaded>,

View file

@ -11,8 +11,8 @@ use rusqlite::{Connection, DatabaseName::Main, OptionalExtension};
use thread_local::ThreadLocal; use thread_local::ThreadLocal;
use tracing::debug; use tracing::debug;
use super::{watchers::Watchers, KeyValueDatabaseEngine, KvTree}; use super::{KeyValueDatabaseEngine, KvTree, watchers::Watchers};
use crate::{database::Config, Result}; use crate::{Result, database::Config};
thread_local! { thread_local! {
static READ_CONNECTION: RefCell<Option<&'static Connection>> = static READ_CONNECTION: RefCell<Option<&'static Connection>> =

View file

@ -1,5 +1,5 @@
use std::{ use std::{
collections::{hash_map, HashMap}, collections::{HashMap, hash_map},
future::Future, future::Future,
pin::Pin, pin::Pin,
sync::RwLock, sync::RwLock,

View file

@ -1,14 +1,14 @@
use std::collections::HashMap; use std::collections::HashMap;
use ruma::{ use ruma::{
RoomId, UserId,
api::client::error::ErrorKind, api::client::error::ErrorKind,
events::{AnyEphemeralRoomEvent, RoomAccountDataEventType}, events::{AnyEphemeralRoomEvent, RoomAccountDataEventType},
serde::Raw, serde::Raw,
RoomId, UserId,
}; };
use crate::{ use crate::{
database::KeyValueDatabase, service, services, utils, Error, Result, Error, Result, database::KeyValueDatabase, service, services, utils,
}; };
impl service::account_data::Data for KeyValueDatabase { impl service::account_data::Data for KeyValueDatabase {

View file

@ -1,6 +1,6 @@
use ruma::api::appservice::Registration; use ruma::api::appservice::Registration;
use crate::{database::KeyValueDatabase, service, utils, Error, Result}; use crate::{Error, Result, database::KeyValueDatabase, service, utils};
impl service::appservice::Data for KeyValueDatabase { impl service::appservice::Data for KeyValueDatabase {
/// Registers an appservice and returns the ID to the caller /// Registers an appservice and returns the ID to the caller

View file

@ -1,15 +1,16 @@
use async_trait::async_trait; use async_trait::async_trait;
use futures_util::{stream::FuturesUnordered, StreamExt}; use futures_util::{StreamExt, stream::FuturesUnordered};
use ruma::{ use ruma::{
DeviceId, ServerName, UserId,
api::federation::discovery::{OldVerifyKey, ServerSigningKeys}, api::federation::discovery::{OldVerifyKey, ServerSigningKeys},
signatures::Ed25519KeyPair, signatures::Ed25519KeyPair,
DeviceId, ServerName, UserId,
}; };
use crate::{ use crate::{
Error, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{self, globals::SigningKeys}, service::{self, globals::SigningKeys},
services, utils, Error, Result, services, utils,
}; };
pub(crate) const COUNTER: &[u8] = b"c"; pub(crate) const COUNTER: &[u8] = b"c";

View file

@ -1,16 +1,16 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma::{ use ruma::{
OwnedRoomId, RoomId, UserId,
api::client::{ api::client::{
backup::{BackupAlgorithm, KeyBackupData, RoomKeyBackup}, backup::{BackupAlgorithm, KeyBackupData, RoomKeyBackup},
error::ErrorKind, error::ErrorKind,
}, },
serde::Raw, serde::Raw,
OwnedRoomId, RoomId, UserId,
}; };
use crate::{ use crate::{
database::KeyValueDatabase, service, services, utils, Error, Result, Error, Result, database::KeyValueDatabase, service, services, utils,
}; };
impl service::key_backups::Data for KeyValueDatabase { impl service::key_backups::Data for KeyValueDatabase {

View file

@ -1,12 +1,13 @@
use ruma::OwnedMxcUri; use ruma::OwnedMxcUri;
use crate::{ use crate::{
Error, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{ service::{
self, self,
media::{FileMeta, MediaFileKey}, media::{FileMeta, MediaFileKey},
}, },
utils, Error, Result, utils,
}; };
#[derive(Debug, Eq, PartialEq)] #[derive(Debug, Eq, PartialEq)]

View file

@ -1,9 +1,9 @@
use ruma::{ use ruma::{
api::client::push::{set_pusher, Pusher},
UserId, UserId,
api::client::push::{Pusher, set_pusher},
}; };
use crate::{database::KeyValueDatabase, service, utils, Error, Result}; use crate::{Error, Result, database::KeyValueDatabase, service, utils};
impl service::pusher::Data for KeyValueDatabase { impl service::pusher::Data for KeyValueDatabase {
fn set_pusher( fn set_pusher(

View file

@ -1,10 +1,10 @@
use ruma::{ use ruma::{
api::client::error::ErrorKind, OwnedRoomAliasId, OwnedRoomId, RoomAliasId, OwnedRoomAliasId, OwnedRoomId, RoomAliasId, RoomId,
RoomId, api::client::error::ErrorKind,
}; };
use crate::{ use crate::{
database::KeyValueDatabase, service, services, utils, Error, Result, Error, Result, database::KeyValueDatabase, service, services, utils,
}; };
impl service::rooms::alias::Data for KeyValueDatabase { impl service::rooms::alias::Data for KeyValueDatabase {

View file

@ -1,9 +1,10 @@
use std::{collections::HashSet, mem::size_of}; use std::{collections::HashSet, mem::size_of};
use crate::{ use crate::{
Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{self, rooms::short::ShortEventId}, service::{self, rooms::short::ShortEventId},
utils, Result, utils,
}; };
impl service::rooms::auth_chain::Data for KeyValueDatabase { impl service::rooms::auth_chain::Data for KeyValueDatabase {

View file

@ -1,6 +1,6 @@
use ruma::{OwnedRoomId, RoomId}; use ruma::{OwnedRoomId, RoomId};
use crate::{database::KeyValueDatabase, service, utils, Error, Result}; use crate::{Error, Result, database::KeyValueDatabase, service, utils};
impl service::rooms::directory::Data for KeyValueDatabase { impl service::rooms::directory::Data for KeyValueDatabase {
#[tracing::instrument(skip(self))] #[tracing::instrument(skip(self))]

View file

@ -1,10 +1,10 @@
use ruma::{ use ruma::{
events::receipt::ReceiptEvent, serde::Raw, CanonicalJsonObject, CanonicalJsonObject, OwnedUserId, RoomId, UserId,
OwnedUserId, RoomId, UserId, events::receipt::ReceiptEvent, serde::Raw,
}; };
use crate::{ use crate::{
database::KeyValueDatabase, service, services, utils, Error, Result, Error, Result, database::KeyValueDatabase, service, services, utils,
}; };
impl service::rooms::edus::read_receipt::Data for KeyValueDatabase { impl service::rooms::edus::read_receipt::Data for KeyValueDatabase {

View file

@ -1,6 +1,6 @@
use ruma::{DeviceId, RoomId, UserId}; use ruma::{DeviceId, RoomId, UserId};
use crate::{database::KeyValueDatabase, service, Result}; use crate::{Result, database::KeyValueDatabase, service};
impl service::rooms::lazy_loading::Data for KeyValueDatabase { impl service::rooms::lazy_loading::Data for KeyValueDatabase {
fn lazy_load_was_sent_before( fn lazy_load_was_sent_before(

View file

@ -1,7 +1,7 @@
use ruma::{OwnedRoomId, RoomId}; use ruma::{OwnedRoomId, RoomId};
use crate::{ use crate::{
database::KeyValueDatabase, service, services, utils, Error, Result, Error, Result, database::KeyValueDatabase, service, services, utils,
}; };
impl service::rooms::metadata::Data for KeyValueDatabase { impl service::rooms::metadata::Data for KeyValueDatabase {

View file

@ -1,6 +1,6 @@
use ruma::{CanonicalJsonObject, EventId}; use ruma::{CanonicalJsonObject, EventId};
use crate::{database::KeyValueDatabase, service, Error, Result}; use crate::{Error, Result, database::KeyValueDatabase, service};
impl service::rooms::outlier::Data for KeyValueDatabase { impl service::rooms::outlier::Data for KeyValueDatabase {
fn get_outlier_pdu_json( fn get_outlier_pdu_json(

View file

@ -3,6 +3,7 @@ use std::sync::Arc;
use ruma::{EventId, RoomId, UserId}; use ruma::{EventId, RoomId, UserId};
use crate::{ use crate::{
Error, PduEvent, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{ service::{
self, self,
@ -11,7 +12,7 @@ use crate::{
timeline::{PduCount, PduId}, timeline::{PduCount, PduId},
}, },
}, },
services, utils, Error, PduEvent, Result, services, utils,
}; };
impl service::rooms::pdu_metadata::Data for KeyValueDatabase { impl service::rooms::pdu_metadata::Data for KeyValueDatabase {

View file

@ -1,12 +1,13 @@
use ruma::RoomId; use ruma::RoomId;
use crate::{ use crate::{
Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{ service::{
self, self,
rooms::{short::ShortRoomId, timeline::PduId}, rooms::{short::ShortRoomId, timeline::PduId},
}, },
services, utils, Result, services, utils,
}; };
/// Splits a string into tokens used as keys in the search inverted index /// Splits a string into tokens used as keys in the search inverted index

View file

@ -1,8 +1,9 @@
use std::sync::Arc; use std::sync::Arc;
use ruma::{events::StateEventType, EventId, RoomId}; use ruma::{EventId, RoomId, events::StateEventType};
use crate::{ use crate::{
Error, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{ service::{
self, self,
@ -10,7 +11,7 @@ use crate::{
ShortEventId, ShortRoomId, ShortStateHash, ShortStateKey, ShortEventId, ShortRoomId, ShortStateHash, ShortStateKey,
}, },
}, },
services, utils, Error, Result, services, utils,
}; };
impl service::rooms::short::Data for KeyValueDatabase { impl service::rooms::short::Data for KeyValueDatabase {

View file

@ -3,6 +3,7 @@ use std::{collections::HashSet, sync::Arc};
use ruma::{EventId, OwnedEventId, OwnedRoomId, RoomId}; use ruma::{EventId, OwnedEventId, OwnedRoomId, RoomId};
use crate::{ use crate::{
Error, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{ service::{
self, self,
@ -10,7 +11,6 @@ use crate::{
rooms::short::{ShortEventId, ShortStateHash}, rooms::short::{ShortEventId, ShortStateHash},
}, },
utils::{self, on_demand_hashmap::KeyToken}, utils::{self, on_demand_hashmap::KeyToken},
Error, Result,
}; };
impl service::rooms::state::Data for KeyValueDatabase { impl service::rooms::state::Data for KeyValueDatabase {

View file

@ -1,9 +1,10 @@
use ruma::EventId; use ruma::EventId;
use crate::{ use crate::{
Error, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{self, rooms::short::ShortStateHash}, service::{self, rooms::short::ShortStateHash},
utils, Error, Result, utils,
}; };
impl service::rooms::state_accessor::Data for KeyValueDatabase { impl service::rooms::state_accessor::Data for KeyValueDatabase {

View file

@ -1,15 +1,16 @@
use std::collections::HashSet; use std::collections::HashSet;
use ruma::{ use ruma::{
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
events::{AnyStrippedStateEvent, AnySyncStateEvent}, events::{AnyStrippedStateEvent, AnySyncStateEvent},
serde::Raw, serde::Raw,
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
}; };
use crate::{ use crate::{
Error, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{self, appservice::RegistrationInfo}, service::{self, appservice::RegistrationInfo},
services, utils, Error, Result, services, utils,
}; };
impl service::rooms::state_cache::Data for KeyValueDatabase { impl service::rooms::state_cache::Data for KeyValueDatabase {

View file

@ -1,15 +1,16 @@
use std::{collections::HashSet, mem::size_of, sync::Arc}; use std::{collections::HashSet, mem::size_of, sync::Arc};
use crate::{ use crate::{
Error, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{ service::{
self, self,
rooms::{ rooms::{
short::ShortStateHash, short::ShortStateHash,
state_compressor::{data::StateDiff, CompressedStateEvent}, state_compressor::{CompressedStateEvent, data::StateDiff},
}, },
}, },
utils, Error, Result, utils,
}; };
impl service::rooms::state_compressor::Data for KeyValueDatabase { impl service::rooms::state_compressor::Data for KeyValueDatabase {

View file

@ -1,12 +1,13 @@
use ruma::{ use ruma::{
api::client::threads::get_threads::v1::IncludeThreads, OwnedUserId, RoomId, OwnedUserId, RoomId, UserId,
UserId, api::client::threads::get_threads::v1::IncludeThreads,
}; };
use crate::{ use crate::{
Error, PduEvent, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{self, rooms::timeline::PduId}, service::{self, rooms::timeline::PduId},
services, utils, Error, PduEvent, Result, services, utils,
}; };
impl service::rooms::threads::Data for KeyValueDatabase { impl service::rooms::threads::Data for KeyValueDatabase {

View file

@ -1,15 +1,16 @@
use std::{mem::size_of, sync::Arc}; use std::{mem::size_of, sync::Arc};
use ruma::{ use ruma::{
api::client::error::ErrorKind, CanonicalJsonObject, EventId, OwnedUserId, CanonicalJsonObject, EventId, OwnedUserId, RoomId, UserId,
RoomId, UserId, api::client::error::ErrorKind,
}; };
use service::rooms::timeline::PduCount; use service::rooms::timeline::PduCount;
use crate::{ use crate::{
Error, PduEvent, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{self, rooms::timeline::PduId}, service::{self, rooms::timeline::PduId},
services, utils, Error, PduEvent, Result, services, utils,
}; };
impl service::rooms::timeline::Data for KeyValueDatabase { impl service::rooms::timeline::Data for KeyValueDatabase {

View file

@ -1,9 +1,10 @@
use ruma::{OwnedRoomId, OwnedUserId, RoomId, UserId}; use ruma::{OwnedRoomId, OwnedUserId, RoomId, UserId};
use crate::{ use crate::{
Error, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{self, rooms::short::ShortStateHash}, service::{self, rooms::short::ShortStateHash},
services, utils, Error, Result, services, utils,
}; };
impl service::rooms::user::Data for KeyValueDatabase { impl service::rooms::user::Data for KeyValueDatabase {

View file

@ -1,13 +1,14 @@
use ruma::{serde::Raw, ServerName, UserId}; use ruma::{ServerName, UserId, serde::Raw};
use crate::{ use crate::{
Error, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{ service::{
self, self,
rooms::timeline::PduId, rooms::timeline::PduId,
sending::{Destination, RequestKey, SendingEventType}, sending::{Destination, RequestKey, SendingEventType},
}, },
services, utils, Error, Result, services, utils,
}; };
impl service::sending::Data for KeyValueDatabase { impl service::sending::Data for KeyValueDatabase {

View file

@ -1,6 +1,6 @@
use ruma::{DeviceId, TransactionId, UserId}; use ruma::{DeviceId, TransactionId, UserId};
use crate::{database::KeyValueDatabase, service, Result}; use crate::{Result, database::KeyValueDatabase, service};
impl service::transaction_ids::Data for KeyValueDatabase { impl service::transaction_ids::Data for KeyValueDatabase {
fn add_txnid( fn add_txnid(

View file

@ -1,9 +1,9 @@
use ruma::{ use ruma::{
api::client::{error::ErrorKind, uiaa::UiaaInfo},
DeviceId, UserId, DeviceId, UserId,
api::client::{error::ErrorKind, uiaa::UiaaInfo},
}; };
use crate::{database::KeyValueDatabase, service, Error, Result}; use crate::{Error, Result, database::KeyValueDatabase, service};
impl service::uiaa::Data for KeyValueDatabase { impl service::uiaa::Data for KeyValueDatabase {
fn update_uiaa_session( fn update_uiaa_session(

View file

@ -1,20 +1,21 @@
use std::{collections::BTreeMap, mem::size_of}; use std::{collections::BTreeMap, mem::size_of};
use ruma::{ use ruma::{
DeviceId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, OneTimeKeyName,
OwnedDeviceId, OwnedKeyId, OwnedMxcUri, OwnedOneTimeKeyId, OwnedUserId,
UInt, UserId,
api::client::{device::Device, error::ErrorKind, filter::FilterDefinition}, api::client::{device::Device, error::ErrorKind, filter::FilterDefinition},
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey}, encryption::{CrossSigningKey, DeviceKeys, OneTimeKey},
events::{AnyToDeviceEvent, StateEventType}, events::{AnyToDeviceEvent, StateEventType},
serde::Raw, serde::Raw,
DeviceId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, OneTimeKeyName,
OwnedDeviceId, OwnedKeyId, OwnedMxcUri, OwnedOneTimeKeyId, OwnedUserId,
UInt, UserId,
}; };
use tracing::warn; use tracing::warn;
use crate::{ use crate::{
Error, Result,
database::KeyValueDatabase, database::KeyValueDatabase,
service::{self, users::clean_signatures}, service::{self, users::clean_signatures},
services, utils, Error, Result, services, utils,
}; };
impl service::users::Data for KeyValueDatabase { impl service::users::Data for KeyValueDatabase {

View file

@ -20,7 +20,7 @@ mod utils;
pub(crate) use api::ruma_wrapper::{Ar, Ra}; pub(crate) use api::ruma_wrapper::{Ar, Ra};
pub(crate) use config::Config; pub(crate) use config::Config;
pub(crate) use service::{pdu::PduEvent, services, Services}; pub(crate) use service::{Services, pdu::PduEvent, services};
pub(crate) use utils::error::{Error, Result}; pub(crate) use utils::error::{Error, Result};
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))] #[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
@ -114,7 +114,7 @@ async fn main() -> ExitCode {
#[cfg(unix)] #[cfg(unix)]
#[tracing::instrument(err)] #[tracing::instrument(err)]
fn maximize_fd_limit() -> Result<(), nix::errno::Errno> { fn maximize_fd_limit() -> Result<(), nix::errno::Errno> {
use nix::sys::resource::{getrlimit, setrlimit, Resource}; use nix::sys::resource::{Resource, getrlimit, setrlimit};
use tracing::debug; use tracing::debug;
let res = Resource::RLIMIT_NOFILE; let res = Resource::RLIMIT_NOFILE;

View file

@ -14,22 +14,23 @@ use axum::{
response::Response, response::Response,
}; };
use http::Method; use http::Method;
use opentelemetry::{metrics::MeterProvider, trace::TracerProvider, KeyValue}; use opentelemetry::{KeyValue, metrics::MeterProvider, trace::TracerProvider};
use opentelemetry_otlp::WithExportConfig; use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::{ use opentelemetry_sdk::{
metrics::{new_view, Aggregation, Instrument, SdkMeterProvider, Stream},
Resource, Resource,
metrics::{Aggregation, Instrument, SdkMeterProvider, Stream, new_view},
}; };
use strum::{AsRefStr, IntoStaticStr}; use strum::{AsRefStr, IntoStaticStr};
use thiserror::Error; use thiserror::Error;
use tokio::time::Instant; use tokio::time::Instant;
use tracing::{subscriber::SetGlobalDefaultError, Span}; use tracing::{Span, subscriber::SetGlobalDefaultError};
use tracing_flame::{FlameLayer, FlushGuard}; use tracing_flame::{FlameLayer, FlushGuard};
use tracing_opentelemetry::OtelData; use tracing_opentelemetry::OtelData;
use tracing_subscriber::{ use tracing_subscriber::{
EnvFilter, Layer, Registry,
layer::SubscriberExt, layer::SubscriberExt,
registry::{LookupSpan, SpanData}, registry::{LookupSpan, SpanData},
reload, EnvFilter, Layer, Registry, reload,
}; };
use crate::{ use crate::{

View file

@ -1,6 +1,6 @@
use std::sync::{Arc, OnceLock}; use std::sync::{Arc, OnceLock};
use crate::{observability::FilterReloadHandles, Config, Result}; use crate::{Config, Result, observability::FilterReloadHandles};
pub(crate) mod account_data; pub(crate) mod account_data;
pub(crate) mod admin; pub(crate) mod admin;

View file

@ -1,9 +1,9 @@
use std::collections::HashMap; use std::collections::HashMap;
use ruma::{ use ruma::{
RoomId, UserId,
events::{AnyEphemeralRoomEvent, RoomAccountDataEventType}, events::{AnyEphemeralRoomEvent, RoomAccountDataEventType},
serde::Raw, serde::Raw,
RoomId, UserId,
}; };
use crate::Result; use crate::Result;

View file

@ -3,8 +3,11 @@ use std::{collections::BTreeMap, fmt::Write, sync::Arc, time::Instant};
use clap::{Parser, Subcommand, ValueEnum}; use clap::{Parser, Subcommand, ValueEnum};
use regex::Regex; use regex::Regex;
use ruma::{ use ruma::{
EventId, MilliSecondsSinceUnixEpoch, OwnedMxcUri, OwnedRoomId,
OwnedServerName, RoomId, RoomVersionId, ServerName, UserId,
api::appservice::Registration, api::appservice::Registration,
events::{ events::{
TimelineEventType,
push_rules::{PushRulesEvent, PushRulesEventContent}, push_rules::{PushRulesEvent, PushRulesEventContent},
room::{ room::{
canonical_alias::RoomCanonicalAliasEventContent, canonical_alias::RoomCanonicalAliasEventContent,
@ -20,22 +23,19 @@ use ruma::{
power_levels::RoomPowerLevelsEventContent, power_levels::RoomPowerLevelsEventContent,
topic::RoomTopicEventContent, topic::RoomTopicEventContent,
}, },
TimelineEventType,
}, },
signatures::verify_json, signatures::verify_json,
EventId, MilliSecondsSinceUnixEpoch, OwnedMxcUri, OwnedRoomId,
OwnedServerName, RoomId, RoomVersionId, ServerName, UserId,
}; };
use serde_json::value::to_raw_value; use serde_json::value::to_raw_value;
use tokio::sync::{mpsc, Mutex, RwLock}; use tokio::sync::{Mutex, RwLock, mpsc};
use tracing::warn; use tracing::warn;
use super::pdu::PduBuilder; use super::pdu::PduBuilder;
use crate::{ use crate::{
api::client_server::{leave_all_rooms, AUTO_GEN_PASSWORD_LENGTH}, Error, PduEvent, Result,
api::client_server::{AUTO_GEN_PASSWORD_LENGTH, leave_all_rooms},
services, services,
utils::{self, dbg_truncate_str, room_version::RoomVersion}, utils::{self, dbg_truncate_str, room_version::RoomVersion},
Error, PduEvent, Result,
}; };
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
@ -691,7 +691,7 @@ impl Service {
"The supplied username is not a valid \ "The supplied username is not a valid \
username: {e}" username: {e}"
), ),
)) ));
} }
}; };
@ -746,7 +746,7 @@ impl Service {
"The supplied username is not a valid \ "The supplied username is not a valid \
username: {e}" username: {e}"
), ),
)) ));
} }
}; };
if user_id.is_historical() { if user_id.is_historical() {

View file

@ -3,8 +3,8 @@ use std::collections::BTreeMap;
use futures_util::Future; use futures_util::Future;
use regex::RegexSet; use regex::RegexSet;
use ruma::{ use ruma::{
api::appservice::{Namespace, Registration},
RoomAliasId, UserId, RoomAliasId, UserId,
api::appservice::{Namespace, Registration},
}; };
use tokio::sync::RwLock; use tokio::sync::RwLock;

View file

@ -7,13 +7,13 @@ use std::{
net::{IpAddr, SocketAddr}, net::{IpAddr, SocketAddr},
path::PathBuf, path::PathBuf,
sync::{ sync::{
atomic::{self, AtomicBool},
Arc, RwLock as StdRwLock, Arc, RwLock as StdRwLock,
atomic::{self, AtomicBool},
}, },
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use base64::{engine::general_purpose, Engine as _}; use base64::{Engine as _, engine::general_purpose};
use futures_util::FutureExt; use futures_util::FutureExt;
use hyper::service::Service as _; use hyper::service::Service as _;
use hyper_util::{ use hyper_util::{
@ -21,29 +21,29 @@ use hyper_util::{
}; };
use reqwest::dns::{Addrs, Name, Resolve, Resolving}; use reqwest::dns::{Addrs, Name, Resolve, Resolving};
use ruma::{ use ruma::{
api::federation::discovery::ServerSigningKeys,
events::{
push_rules::PushRulesEventContent,
room::message::RoomMessageEventContent, GlobalAccountDataEvent,
GlobalAccountDataEventType,
},
push::Ruleset,
serde::Base64,
DeviceId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomAliasId, DeviceId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomAliasId,
OwnedRoomId, OwnedServerName, OwnedUserId, RoomAliasId, RoomVersionId, OwnedRoomId, OwnedServerName, OwnedUserId, RoomAliasId, RoomVersionId,
ServerName, UInt, UserId, ServerName, UInt, UserId,
api::federation::discovery::ServerSigningKeys,
events::{
GlobalAccountDataEvent, GlobalAccountDataEventType,
push_rules::PushRulesEventContent,
room::message::RoomMessageEventContent,
},
push::Ruleset,
serde::Base64,
}; };
use tokio::sync::{broadcast, Mutex, RwLock, Semaphore}; use tokio::sync::{Mutex, RwLock, Semaphore, broadcast};
use tracing::{error, warn, Instrument}; use tracing::{Instrument, error, warn};
use trust_dns_resolver::TokioAsyncResolver; use trust_dns_resolver::TokioAsyncResolver;
use crate::{ use crate::{
Config, Error, Result,
api::server_server::FedDest, api::server_server::FedDest,
observability::FilterReloadHandles, observability::FilterReloadHandles,
service::media::MediaFileKey, service::media::MediaFileKey,
services, services,
utils::on_demand_hashmap::{OnDemandHashMap, TokenSet}, utils::on_demand_hashmap::{OnDemandHashMap, TokenSet},
Config, Error, Result,
}; };
mod data; mod data;

View file

@ -5,14 +5,14 @@ use std::{
use async_trait::async_trait; use async_trait::async_trait;
use ruma::{ use ruma::{
DeviceId, MilliSecondsSinceUnixEpoch, ServerName, UserId,
api::federation::discovery::{OldVerifyKey, ServerSigningKeys, VerifyKey}, api::federation::discovery::{OldVerifyKey, ServerSigningKeys, VerifyKey},
serde::Base64, serde::Base64,
signatures::Ed25519KeyPair, signatures::Ed25519KeyPair,
DeviceId, MilliSecondsSinceUnixEpoch, ServerName, UserId,
}; };
use serde::Deserialize; use serde::Deserialize;
use crate::{services, Result}; use crate::{Result, services};
/// Similar to [`ServerSigningKeys`], but drops a few unnecessary fields we /// Similar to [`ServerSigningKeys`], but drops a few unnecessary fields we
/// don't require post-validation /// don't require post-validation
@ -88,7 +88,7 @@ pub(crate) trait Data: Send + Sync {
fn next_count(&self) -> Result<u64>; fn next_count(&self) -> Result<u64>;
fn current_count(&self) -> Result<u64>; fn current_count(&self) -> Result<u64>;
async fn watch(&self, user_id: &UserId, device_id: &DeviceId) async fn watch(&self, user_id: &UserId, device_id: &DeviceId)
-> Result<()>; -> Result<()>;
fn cleanup(&self) -> Result<()>; fn cleanup(&self) -> Result<()>;
fn load_keypair(&self) -> Result<Ed25519KeyPair>; fn load_keypair(&self) -> Result<Ed25519KeyPair>;
fn remove_keypair(&self) -> Result<()>; fn remove_keypair(&self) -> Result<()>;

View file

@ -1,9 +1,9 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma::{ use ruma::{
OwnedRoomId, RoomId, UserId,
api::client::backup::{BackupAlgorithm, KeyBackupData, RoomKeyBackup}, api::client::backup::{BackupAlgorithm, KeyBackupData, RoomKeyBackup},
serde::Raw, serde::Raw,
OwnedRoomId, RoomId, UserId,
}; };
use crate::Result; use crate::Result;

View file

@ -2,8 +2,8 @@ use std::io::Cursor;
use image::imageops::FilterType; use image::imageops::FilterType;
use ruma::{ use ruma::{
api::client::error::ErrorKind, http_headers::ContentDisposition, OwnedMxcUri, api::client::error::ErrorKind,
OwnedMxcUri, http_headers::ContentDisposition,
}; };
use tokio::{ use tokio::{
fs::{self, File}, fs::{self, File},
@ -11,7 +11,7 @@ use tokio::{
}; };
use tracing::{debug, warn}; use tracing::{debug, warn};
use crate::{services, utils, Error, Result}; use crate::{Error, Result, services, utils};
mod data; mod data;
@ -392,7 +392,7 @@ impl Service {
let mut file = match File::open(path).await { let mut file = match File::open(path).await {
Ok(file) => file, Ok(file) => file,
Err(e) if e.kind() == std::io::ErrorKind::NotFound => { Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
return Ok(None) return Ok(None);
} }
Err(e) => return Err(e.into()), Err(e) => return Err(e.into()),
}; };

View file

@ -1,26 +1,27 @@
use std::{cmp::Ordering, collections::BTreeMap, sync::Arc}; use std::{cmp::Ordering, collections::BTreeMap, sync::Arc};
use ruma::{ use ruma::{
CanonicalJsonObject, CanonicalJsonValue, EventId,
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedUserId, RoomId,
RoomVersionId, UInt, UserId,
canonical_json::redact_content_in_place, canonical_json::redact_content_in_place,
events::{ events::{
AnyEphemeralRoomEvent, AnyMessageLikeEvent, AnyStateEvent,
AnyStrippedStateEvent, AnySyncStateEvent, AnySyncTimelineEvent,
AnyTimelineEvent, StateEvent, TimelineEventType,
room::{ room::{
member::RoomMemberEventContent, member::RoomMemberEventContent,
redaction::RoomRedactionEventContent, redaction::RoomRedactionEventContent,
}, },
space::child::HierarchySpaceChildEvent, space::child::HierarchySpaceChildEvent,
AnyEphemeralRoomEvent, AnyMessageLikeEvent, AnyStateEvent,
AnyStrippedStateEvent, AnySyncStateEvent, AnySyncTimelineEvent,
AnyTimelineEvent, StateEvent, TimelineEventType,
}, },
serde::Raw, serde::Raw,
state_res, CanonicalJsonObject, CanonicalJsonValue, EventId, state_res,
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedUserId, RoomId,
RoomVersionId, UInt, UserId,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::{ use serde_json::{
json, json,
value::{to_raw_value, RawValue as RawJsonValue}, value::{RawValue as RawJsonValue, to_raw_value},
}; };
use tracing::warn; use tracing::warn;

View file

@ -2,30 +2,31 @@ use std::{fmt::Debug, mem};
use bytes::BytesMut; use bytes::BytesMut;
use ruma::{ use ruma::{
RoomId, UInt, UserId,
api::{ api::{
client::push::{set_pusher, Pusher, PusherKind}, IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken,
client::push::{Pusher, PusherKind, set_pusher},
push_gateway::send_event_notification::{ push_gateway::send_event_notification::{
self, self,
v1::{ v1::{
Device, Notification, NotificationCounts, NotificationPriority, Device, Notification, NotificationCounts, NotificationPriority,
}, },
}, },
IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken,
}, },
events::{ events::{
room::power_levels::RoomPowerLevelsEventContent, AnySyncTimelineEvent, AnySyncTimelineEvent, StateEventType, TimelineEventType,
StateEventType, TimelineEventType, room::power_levels::RoomPowerLevelsEventContent,
}, },
push::{ push::{
Action, PushConditionPowerLevelsCtx, PushConditionRoomCtx, PushFormat, Action, PushConditionPowerLevelsCtx, PushConditionRoomCtx, PushFormat,
Ruleset, Tweak, Ruleset, Tweak,
}, },
serde::Raw, serde::Raw,
uint, RoomId, UInt, UserId, uint,
}; };
use tracing::warn; use tracing::warn;
use crate::{services, utils, Error, PduEvent, Result}; use crate::{Error, PduEvent, Result, services, utils};
mod data; mod data;

View file

@ -1,6 +1,6 @@
use ruma::{ use ruma::{
api::client::push::{set_pusher, Pusher},
UserId, UserId,
api::client::push::{Pusher, set_pusher},
}; };
use crate::Result; use crate::Result;

View file

@ -1,10 +1,10 @@
use http::StatusCode; use http::StatusCode;
use ruma::{ use ruma::{
api::{client::error::ErrorKind, federation},
OwnedRoomAliasId, OwnedRoomId, RoomAliasId, RoomId, UserId, OwnedRoomAliasId, OwnedRoomId, RoomAliasId, RoomId, UserId,
api::{client::error::ErrorKind, federation},
}; };
use crate::{services, Error, Result}; use crate::{Error, Result, services};
mod data; mod data;

View file

@ -4,15 +4,15 @@ use std::{
}; };
use lru_cache::LruCache; use lru_cache::LruCache;
use ruma::{api::client::error::ErrorKind, EventId, RoomId}; use ruma::{EventId, RoomId, api::client::error::ErrorKind};
use tracing::{debug, error, warn}; use tracing::{debug, error, warn};
use super::short::ShortEventId; use super::short::ShortEventId;
use crate::{ use crate::{
Error, Result,
observability::{FoundIn, Lookup, METRICS}, observability::{FoundIn, Lookup, METRICS},
services, services,
utils::debug_slice_truncated, utils::debug_slice_truncated,
Error, Result,
}; };
mod data; mod data;

View file

@ -1,6 +1,6 @@
use std::collections::HashSet; use std::collections::HashSet;
use crate::{service::rooms::short::ShortEventId, Result}; use crate::{Result, service::rooms::short::ShortEventId};
pub(crate) trait Data: Send + Sync { pub(crate) trait Data: Send + Sync {
fn get_cached_eventid_authchain( fn get_cached_eventid_authchain(

View file

@ -1,5 +1,5 @@
use ruma::{ use ruma::{
events::receipt::ReceiptEvent, serde::Raw, OwnedUserId, RoomId, UserId, OwnedUserId, RoomId, UserId, events::receipt::ReceiptEvent, serde::Raw,
}; };
use crate::Result; use crate::Result;

View file

@ -1,13 +1,13 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma::{ use ruma::{
events::{typing::TypingEventContent, SyncEphemeralRoomEvent},
OwnedRoomId, OwnedUserId, RoomId, UserId, OwnedRoomId, OwnedUserId, RoomId, UserId,
events::{SyncEphemeralRoomEvent, typing::TypingEventContent},
}; };
use tokio::sync::{broadcast, RwLock}; use tokio::sync::{RwLock, broadcast};
use tracing::trace; use tracing::trace;
use crate::{services, utils, Result}; use crate::{Result, services, utils};
pub(crate) struct Service { pub(crate) struct Service {
// u64 is unix timestamp of timeout // u64 is unix timestamp of timeout

View file

@ -1,11 +1,14 @@
use std::{ use std::{
collections::{hash_map, BTreeMap, HashMap, HashSet}, collections::{BTreeMap, HashMap, HashSet, hash_map},
sync::Arc, sync::Arc,
time::{Duration, Instant, SystemTime}, time::{Duration, Instant, SystemTime},
}; };
use futures_util::{future::BoxFuture, stream::FuturesUnordered, StreamExt}; use futures_util::{StreamExt, future::BoxFuture, stream::FuturesUnordered};
use ruma::{ use ruma::{
CanonicalJsonObject, CanonicalJsonValue, EventId,
MilliSecondsSinceUnixEpoch, OwnedServerName, OwnedServerSigningKeyId,
RoomId, RoomVersionId, ServerName,
api::{ api::{
client::error::ErrorKind, client::error::ErrorKind,
federation::{ federation::{
@ -19,17 +22,15 @@ use ruma::{
}, },
}, },
events::{ events::{
StateEventType, TimelineEventType,
room::{ room::{
redaction::RoomRedactionEventContent, redaction::RoomRedactionEventContent,
server_acl::RoomServerAclEventContent, server_acl::RoomServerAclEventContent,
}, },
StateEventType, TimelineEventType,
}, },
int, int,
state_res::{self, StateMap}, state_res::{self, StateMap},
uint, CanonicalJsonObject, CanonicalJsonValue, EventId, uint,
MilliSecondsSinceUnixEpoch, OwnedServerName, OwnedServerSigningKeyId,
RoomId, RoomVersionId, ServerName,
}; };
use serde::Deserialize; use serde::Deserialize;
use serde_json::value::RawValue as RawJsonValue; use serde_json::value::RawValue as RawJsonValue;
@ -41,10 +42,10 @@ use super::{
timeline::PduId, timeline::PduId,
}; };
use crate::{ use crate::{
Error, PduEvent, Result,
service::{globals::SigningKeys, pdu, rooms::state::ExtractVersion}, service::{globals::SigningKeys, pdu, rooms::state::ExtractVersion},
services, services,
utils::{debug_slice_truncated, room_version::RoomVersion}, utils::{debug_slice_truncated, room_version::RoomVersion},
Error, PduEvent, Result,
}; };
#[derive(Deserialize)] #[derive(Deserialize)]
@ -820,7 +821,7 @@ impl Service {
return Err(Error::bad_database( return Err(Error::bad_database(
"State event's type and state_key \ "State event's type and state_key \
combination exists multiple times.", combination exists multiple times.",
)) ));
} }
} }
} }

View file

@ -1,14 +1,14 @@
use std::sync::Arc; use std::sync::Arc;
use ruma::{ use ruma::{
api::client::relations::get_relating_events,
events::{relation::RelationType, TimelineEventType},
EventId, RoomId, UserId, EventId, RoomId, UserId,
api::client::relations::get_relating_events,
events::{TimelineEventType, relation::RelationType},
}; };
use serde::Deserialize; use serde::Deserialize;
use super::timeline::PduCount; use super::timeline::PduCount;
use crate::{services, PduEvent, Result}; use crate::{PduEvent, Result, services};
mod data; mod data;

View file

@ -3,8 +3,8 @@ use std::sync::Arc;
use ruma::{EventId, RoomId, UserId}; use ruma::{EventId, RoomId, UserId};
use crate::{ use crate::{
service::rooms::{short::ShortRoomId, timeline::PduCount},
PduEvent, Result, PduEvent, Result,
service::rooms::{short::ShortRoomId, timeline::PduCount},
}; };
pub(crate) trait Data: Send + Sync { pub(crate) trait Data: Send + Sync {

View file

@ -1,8 +1,8 @@
use ruma::RoomId; use ruma::RoomId;
use crate::{ use crate::{
service::rooms::{short::ShortRoomId, timeline::PduId},
Result, Result,
service::rooms::{short::ShortRoomId, timeline::PduId},
}; };
pub(crate) trait Data: Send + Sync { pub(crate) trait Data: Send + Sync {

View file

@ -1,7 +1,7 @@
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use lru_cache::LruCache; use lru_cache::LruCache;
use ruma::{events::StateEventType, EventId, OwnedEventId, RoomId}; use ruma::{EventId, OwnedEventId, RoomId, events::StateEventType};
use crate::{ use crate::{
observability::{FoundIn, Lookup, METRICS}, observability::{FoundIn, Lookup, METRICS},

View file

@ -1,6 +1,6 @@
use std::sync::Arc; use std::sync::Arc;
use ruma::{events::StateEventType, EventId, RoomId}; use ruma::{EventId, RoomId, events::StateEventType};
use super::{ShortEventId, ShortRoomId, ShortStateHash, ShortStateKey}; use super::{ShortEventId, ShortRoomId, ShortStateHash, ShortStateKey};
use crate::Result; use crate::Result;

View file

@ -2,14 +2,16 @@ use std::sync::Arc;
use lru_cache::LruCache; use lru_cache::LruCache;
use ruma::{ use ruma::{
OwnedRoomId, RoomId, UserId,
api::{ api::{
client::{ client::{
error::ErrorKind, error::ErrorKind,
space::{get_hierarchy, SpaceHierarchyRoomsChunk}, space::{SpaceHierarchyRoomsChunk, get_hierarchy},
}, },
federation, federation,
}, },
events::{ events::{
StateEventType,
room::{ room::{
avatar::RoomAvatarEventContent, avatar::RoomAvatarEventContent,
canonical_alias::RoomCanonicalAliasEventContent, canonical_alias::RoomCanonicalAliasEventContent,
@ -23,16 +25,14 @@ use ruma::{
topic::RoomTopicEventContent, topic::RoomTopicEventContent,
}, },
space::child::SpaceChildEventContent, space::child::SpaceChildEventContent,
StateEventType,
}, },
space::SpaceRoomJoinRule, space::SpaceRoomJoinRule,
OwnedRoomId, RoomId, UserId,
}; };
use tokio::sync::Mutex; use tokio::sync::Mutex;
use tracing::{debug, error, warn}; use tracing::{debug, error, warn};
use super::state::ExtractType; use super::state::ExtractType;
use crate::{services, Error, PduEvent, Result}; use crate::{Error, PduEvent, Result, services};
pub(crate) enum CachedJoinRule { pub(crate) enum CachedJoinRule {
Full(JoinRule), Full(JoinRule),
@ -288,7 +288,7 @@ impl Service {
_ => { _ => {
return Err(Error::BadServerResponse( return Err(Error::BadServerResponse(
"Unknown join rule", "Unknown join rule",
)) ));
} }
}; };
if self.handle_join_rule( if self.handle_join_rule(

View file

@ -5,27 +5,27 @@ use std::{
}; };
use ruma::{ use ruma::{
EventId, OwnedEventId, OwnedRoomId, RoomId, RoomVersionId, UserId,
api::client::error::ErrorKind, api::client::error::ErrorKind,
events::{ events::{
room::{create::PreviousRoom, member::MembershipState},
AnyStrippedStateEvent, StateEventType, TimelineEventType, AnyStrippedStateEvent, StateEventType, TimelineEventType,
room::{create::PreviousRoom, member::MembershipState},
}, },
room::RoomType, room::RoomType,
serde::Raw, serde::Raw,
state_res::{self, StateMap}, state_res::{self, StateMap},
EventId, OwnedEventId, OwnedRoomId, RoomId, RoomVersionId, UserId,
}; };
use serde::{de::DeserializeOwned, Deserialize}; use serde::{Deserialize, de::DeserializeOwned};
use tracing::warn; use tracing::warn;
use super::{short::ShortStateHash, state_compressor::CompressedStateEvent}; use super::{short::ShortStateHash, state_compressor::CompressedStateEvent};
use crate::{ use crate::{
Error, PduEvent, Result,
service::globals::marker, service::globals::marker,
services, services,
utils::{ utils::{
calculate_hash, debug_slice_truncated, on_demand_hashmap::KeyToken, calculate_hash, debug_slice_truncated, on_demand_hashmap::KeyToken,
}, },
Error, PduEvent, Result,
}; };
mod data; mod data;

Some files were not shown because too many files have changed in this diff Show more