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
error_on_line_overflow = true

View file

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

View file

@ -1,25 +1,26 @@
use register::RegistrationKind;
use ruma::{
UserId,
api::client::{
account::{
change_password, deactivate, get_3pids, get_username_availability,
ThirdPartyIdRemovalStatus, change_password, deactivate, get_3pids,
get_username_availability,
register::{self, LoginType},
request_3pid_management_token_via_email,
request_3pid_management_token_via_msisdn, whoami,
ThirdPartyIdRemovalStatus,
},
error::ErrorKind,
uiaa::{AuthFlow, AuthType, UiaaInfo},
},
events::{
room::message::RoomMessageEventContent, GlobalAccountDataEventType,
GlobalAccountDataEventType, room::message::RoomMessageEventContent,
},
push, UserId,
push,
};
use tracing::{info, warn};
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;

View file

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

View file

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

View file

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

View file

@ -14,7 +14,7 @@ use ruma::{
use serde::Deserialize;
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}`
///

View file

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

View file

@ -8,7 +8,7 @@ use ruma::api::client::{
};
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`
///

View file

@ -1,4 +1,5 @@
use ruma::{
ServerName, UInt,
api::{
client::{
directory::{
@ -12,6 +13,7 @@ use ruma::{
},
directory::{Filter, PublicRoomJoinRule, PublicRoomsChunk, RoomNetwork},
events::{
StateEventType,
room::{
avatar::RoomAvatarEventContent,
canonical_alias::RoomCanonicalAliasEventContent,
@ -22,14 +24,13 @@ use ruma::{
join_rules::{JoinRule, RoomJoinRulesEventContent},
topic::RoomTopicEventContent,
},
StateEventType,
},
uint, ServerName, UInt,
uint,
};
use tracing::{error, info, warn};
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`
@ -185,7 +186,7 @@ pub(crate) async fn get_public_rooms_filtered_helper(
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
"Invalid `since` token",
))
));
}
};

View file

@ -3,7 +3,7 @@ use ruma::api::client::{
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}`
///

View file

@ -1,10 +1,12 @@
use std::{
collections::{hash_map, BTreeMap, HashMap, HashSet},
collections::{BTreeMap, HashMap, HashSet, hash_map},
time::{Duration, Instant},
};
use futures_util::{stream::FuturesUnordered, StreamExt};
use futures_util::{StreamExt, stream::FuturesUnordered};
use ruma::{
OneTimeKeyAlgorithm, OwnedDeviceId, OwnedServerName, OwnedUserId,
ServerName, UserId,
api::{
client::{
error::ErrorKind,
@ -17,14 +19,12 @@ use ruma::{
federation,
},
serde::Raw,
OneTimeKeyAlgorithm, OwnedDeviceId, OwnedServerName, OwnedUserId,
ServerName, UserId,
};
use serde_json::json;
use tracing::debug;
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`
///

View file

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

View file

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

View file

@ -10,8 +10,9 @@ use ruma::{
};
use crate::{
Ar, Error, Ra, Result,
service::{pdu::PduBuilder, rooms::timeline::PduCount},
services, utils, Ar, Error, Ra, Result,
services, utils,
};
/// # `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},
},
events::{
room::member::RoomMemberEventContent, StateEventType, TimelineEventType,
StateEventType, TimelineEventType, room::member::RoomMemberEventContent,
},
};
use serde_json::value::to_raw_value;
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`
///

View file

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

View file

@ -1,18 +1,18 @@
use std::collections::BTreeMap;
use ruma::{
MilliSecondsSinceUnixEpoch,
api::client::{
error::ErrorKind, read_marker::set_read_marker, receipt::create_receipt,
},
events::{
receipt::{ReceiptThread, ReceiptType},
RoomAccountDataEventType,
receipt::{ReceiptThread, ReceiptType},
},
MilliSecondsSinceUnixEpoch,
};
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`
@ -58,7 +58,7 @@ pub(crate) async fn set_read_marker_route(
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
"Read receipt is in backfilled timeline",
))
));
}
PduCount::Normal(c) => c,
};
@ -174,7 +174,7 @@ pub(crate) async fn create_receipt_route(
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
"Read receipt is in backfilled timeline",
))
));
}
PduCount::Normal(c) => c,
};

View file

@ -1,10 +1,10 @@
use ruma::{
api::client::redact::redact_event,
events::{room::redaction::RoomRedactionEventContent, TimelineEventType},
events::{TimelineEventType, room::redaction::RoomRedactionEventContent},
};
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}`
///

View file

@ -6,7 +6,7 @@ use ruma::{
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}`
pub(crate) async fn get_relating_events_with_rel_type_and_event_type_route(

View file

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

View file

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

View file

@ -1,6 +1,7 @@
use std::collections::BTreeMap;
use ruma::{
UInt,
api::client::{
error::ErrorKind,
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`
///
@ -73,7 +74,7 @@ pub(crate) async fn search_events_route(
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
"Invalid next_batch token.",
))
));
}
// Default to the start
None => 0,

View file

@ -1,4 +1,5 @@
use ruma::{
UserId,
api::client::{
error::ErrorKind,
session::{
@ -10,13 +11,12 @@ use ruma::{
},
uiaa::UserIdentifier,
},
UserId,
};
use serde::Deserialize;
use tracing::{info, warn};
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)]
struct Claims {

View file

@ -1,6 +1,6 @@
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`
///

View file

@ -1,21 +1,21 @@
use std::{collections::HashSet, sync::Arc};
use ruma::{
EventId, RoomAliasId, RoomId, UserId,
api::client::{
error::ErrorKind,
state::{get_state_events, get_state_events_for_key, send_state_event},
},
events::{
room::canonical_alias::RoomCanonicalAliasEventContent,
AnyStateEventContent, StateEventType,
room::canonical_alias::RoomCanonicalAliasEventContent,
},
serde::Raw,
EventId, RoomAliasId, RoomId, UserId,
};
use serde::Deserialize;
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}`
///

View file

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

View file

@ -9,23 +9,24 @@ use std::{
};
use ruma::{
JsOption, UInt, UserId,
api::client::{
sync::sync_events::{
self, v4::SlidingOp, DeviceLists, UnreadNotificationsCount,
self, DeviceLists, UnreadNotificationsCount, v4::SlidingOp,
},
uiaa::UiaaResponse,
},
events::{
room::member::{MembershipState, RoomMemberEventContent},
StateEventType, TimelineEventType,
room::member::{MembershipState, RoomMemberEventContent},
},
uint, JsOption, UInt, UserId,
uint,
};
use tracing::{debug, error};
use super::{load_timeline, share_encrypted_room};
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)]

View file

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

View file

@ -3,12 +3,12 @@ use std::collections::BTreeMap;
use ruma::{
api::client::tag::{create_tag, delete_tag, get_tags},
events::{
tag::{TagEvent, TagEventContent},
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}`
///

View file

@ -1,6 +1,6 @@
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`
pub(crate) async fn get_threads_route(

View file

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

View file

@ -1,6 +1,6 @@
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}`
///

View file

@ -1,12 +1,12 @@
use ruma::{
api::client::user_directory::search_users,
events::{
room::join_rules::{JoinRule, RoomJoinRulesEventContent},
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`
///

View file

@ -1,11 +1,11 @@
use std::time::{Duration, SystemTime};
use base64::{engine::general_purpose, Engine as _};
use base64::{Engine as _, engine::general_purpose};
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 crate::{services, Ar, Ra, Result};
use crate::{Ar, Ra, Result, services};
type HmacSha1 = Hmac<Sha1>;

View file

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

View file

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

View file

@ -7,12 +7,18 @@ use std::{
time::Instant,
};
use axum::{response::IntoResponse, Json};
use axum::{Json, response::IntoResponse};
use axum_extra::headers::{Authorization, HeaderMapExt};
use base64::Engine as _;
use get_profile_information::v1::ProfileField;
use ruma::{
CanonicalJsonObject, CanonicalJsonValue, EventId,
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName,
OwnedServerSigningKeyId, OwnedSigningKeyId, OwnedUserId, RoomId,
ServerName, Signatures,
api::{
EndpointError, IncomingResponse, MatrixVersion, OutgoingRequest,
OutgoingResponse, SendAccessToken,
client::error::{Error as RumaError, ErrorKind},
federation::{
authenticated_media,
@ -21,7 +27,7 @@ use ruma::{
device::get_devices::{self, v1::UserDevice},
directory::{get_public_rooms, get_public_rooms_filtered},
discovery::{
get_server_keys, get_server_version, ServerSigningKeys,
ServerSigningKeys, get_server_keys, get_server_version,
},
event::{
get_event, get_missing_events, get_room_state,
@ -40,43 +46,38 @@ use ruma::{
send_transaction_message,
},
},
EndpointError, IncomingResponse, MatrixVersion, OutgoingRequest,
OutgoingResponse, SendAccessToken,
},
directory::{Filter, RoomNetwork},
events::{
StateEventType, TimelineEventType,
receipt::{ReceiptEvent, ReceiptEventContent, ReceiptType},
room::{
join_rules::{JoinRule, RoomJoinRulesEventContent},
member::{MembershipState, RoomMemberEventContent},
},
StateEventType, TimelineEventType,
},
serde::{Base64, JsonObject, Raw},
server_util::authorization::XMatrix,
state_res::Event,
to_device::DeviceIdOrAllDevices,
uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId,
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName,
OwnedServerSigningKeyId, OwnedSigningKeyId, OwnedUserId, RoomId,
ServerName, Signatures,
uint, user_id,
};
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 tracing::{debug, error, field, trace, trace_span, warn};
use super::appservice_server;
use crate::{
Ar, Error, PduEvent, Ra, Result,
api::client_server::{self, claim_keys_helper, get_keys_helper},
observability::{FoundIn, Lookup, METRICS},
service::{
globals::SigningKeys,
pdu::{gen_event_id_canonical_json, PduBuilder},
pdu::{PduBuilder, gen_event_id_canonical_json},
rooms::state::ExtractVersion,
},
services,
utils::{self, dbg_truncate_str, MxcData},
Ar, Error, PduEvent, Ra, Result,
utils::{self, MxcData, dbg_truncate_str},
};
/// 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)]
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]
fn ips_get_default_ports() {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -8,13 +8,14 @@ use std::{
};
use ruma::{
events::{push_rules::PushRulesEvent, GlobalAccountDataEventType},
push::Ruleset,
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::{
Config, Error, Result,
config::DatabaseBackend,
service::{
media::MediaFileKey,
@ -23,7 +24,7 @@ use crate::{
state_compressor::CompressedStateEvent,
},
},
services, utils, Config, Error, Result,
services, utils,
};
pub(crate) mod abstraction;
@ -1031,7 +1032,7 @@ impl KeyValueDatabase {
use std::time::{Duration, Instant};
#[cfg(unix)]
use tokio::signal::unix::{signal, SignalKind};
use tokio::signal::unix::{SignalKind, signal};
use tokio::time::interval;
let timer_interval = Duration::from_secs(u64::from(

View file

@ -13,9 +13,9 @@ use rocksdb::{
use tracing::Level;
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 {
rocks: DBWithThreadMode<MultiThreaded>,

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
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 {
/// Registers an appservice and returns the ID to the caller

View file

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

View file

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

View file

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

View file

@ -1,9 +1,9 @@
use ruma::{
api::client::push::{set_pusher, Pusher},
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 {
fn set_pusher(

View file

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

View file

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

View file

@ -1,6 +1,6 @@
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 {
#[tracing::instrument(skip(self))]

View file

@ -1,10 +1,10 @@
use ruma::{
events::receipt::ReceiptEvent, serde::Raw, CanonicalJsonObject,
OwnedUserId, RoomId, UserId,
CanonicalJsonObject, OwnedUserId, RoomId, UserId,
events::receipt::ReceiptEvent, serde::Raw,
};
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 {

View file

@ -1,6 +1,6 @@
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 {
fn lazy_load_was_sent_before(

View file

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

View file

@ -1,6 +1,6 @@
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 {
fn get_outlier_pdu_json(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,10 @@
use ruma::{OwnedRoomId, OwnedUserId, RoomId, UserId};
use crate::{
Error, Result,
database::KeyValueDatabase,
service::{self, rooms::short::ShortStateHash},
services, utils, Error, Result,
services, utils,
};
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::{
Error, Result,
database::KeyValueDatabase,
service::{
self,
rooms::timeline::PduId,
sending::{Destination, RequestKey, SendingEventType},
},
services, utils, Error, Result,
services, utils,
};
impl service::sending::Data for KeyValueDatabase {

View file

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

View file

@ -1,9 +1,9 @@
use ruma::{
api::client::{error::ErrorKind, uiaa::UiaaInfo},
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 {
fn update_uiaa_session(

View file

@ -1,20 +1,21 @@
use std::{collections::BTreeMap, mem::size_of};
use ruma::{
DeviceId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, OneTimeKeyName,
OwnedDeviceId, OwnedKeyId, OwnedMxcUri, OwnedOneTimeKeyId, OwnedUserId,
UInt, UserId,
api::client::{device::Device, error::ErrorKind, filter::FilterDefinition},
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey},
events::{AnyToDeviceEvent, StateEventType},
serde::Raw,
DeviceId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, OneTimeKeyName,
OwnedDeviceId, OwnedKeyId, OwnedMxcUri, OwnedOneTimeKeyId, OwnedUserId,
UInt, UserId,
};
use tracing::warn;
use crate::{
Error, Result,
database::KeyValueDatabase,
service::{self, users::clean_signatures},
services, utils, Error, Result,
services, utils,
};
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 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};
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
@ -114,7 +114,7 @@ async fn main() -> ExitCode {
#[cfg(unix)]
#[tracing::instrument(err)]
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;
let res = Resource::RLIMIT_NOFILE;

View file

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

View file

@ -1,6 +1,6 @@
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 admin;

View file

@ -1,9 +1,9 @@
use std::collections::HashMap;
use ruma::{
RoomId, UserId,
events::{AnyEphemeralRoomEvent, RoomAccountDataEventType},
serde::Raw,
RoomId, UserId,
};
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 regex::Regex;
use ruma::{
EventId, MilliSecondsSinceUnixEpoch, OwnedMxcUri, OwnedRoomId,
OwnedServerName, RoomId, RoomVersionId, ServerName, UserId,
api::appservice::Registration,
events::{
TimelineEventType,
push_rules::{PushRulesEvent, PushRulesEventContent},
room::{
canonical_alias::RoomCanonicalAliasEventContent,
@ -20,22 +23,19 @@ use ruma::{
power_levels::RoomPowerLevelsEventContent,
topic::RoomTopicEventContent,
},
TimelineEventType,
},
signatures::verify_json,
EventId, MilliSecondsSinceUnixEpoch, OwnedMxcUri, OwnedRoomId,
OwnedServerName, RoomId, RoomVersionId, ServerName, UserId,
};
use serde_json::value::to_raw_value;
use tokio::sync::{mpsc, Mutex, RwLock};
use tokio::sync::{Mutex, RwLock, mpsc};
use tracing::warn;
use super::pdu::PduBuilder;
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,
utils::{self, dbg_truncate_str, room_version::RoomVersion},
Error, PduEvent, Result,
};
#[derive(Debug, Parser)]
@ -691,7 +691,7 @@ impl Service {
"The supplied username is not a valid \
username: {e}"
),
))
));
}
};
@ -746,7 +746,7 @@ impl Service {
"The supplied username is not a valid \
username: {e}"
),
))
));
}
};
if user_id.is_historical() {

View file

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

View file

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

View file

@ -5,14 +5,14 @@ use std::{
use async_trait::async_trait;
use ruma::{
DeviceId, MilliSecondsSinceUnixEpoch, ServerName, UserId,
api::federation::discovery::{OldVerifyKey, ServerSigningKeys, VerifyKey},
serde::Base64,
signatures::Ed25519KeyPair,
DeviceId, MilliSecondsSinceUnixEpoch, ServerName, UserId,
};
use serde::Deserialize;
use crate::{services, Result};
use crate::{Result, services};
/// Similar to [`ServerSigningKeys`], but drops a few unnecessary fields we
/// don't require post-validation

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,15 +4,15 @@ use std::{
};
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 super::short::ShortEventId;
use crate::{
Error, Result,
observability::{FoundIn, Lookup, METRICS},
services,
utils::debug_slice_truncated,
Error, Result,
};
mod data;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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