Hot-Reloading Refactor
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
ae1a4fd283
commit
6c1434c165
212 changed files with 5679 additions and 4206 deletions
|
@ -19,9 +19,10 @@ use tracing::{error, info, warn};
|
|||
|
||||
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
|
||||
use crate::{
|
||||
api::client_server::{self, join_room_by_id_helper},
|
||||
service, services,
|
||||
utils::{self, user_id::user_is_local},
|
||||
client_server::{self, join_room_by_id_helper},
|
||||
service::user_is_local,
|
||||
services,
|
||||
utils::{self},
|
||||
Error, Result, Ruma,
|
||||
};
|
||||
|
||||
|
|
|
@ -13,8 +13,9 @@ use ruma::{
|
|||
use tracing::debug;
|
||||
|
||||
use crate::{
|
||||
debug_info, debug_warn, service::appservice::RegistrationInfo, services, utils::server_name::server_is_ours, Error,
|
||||
Result, Ruma,
|
||||
debug_info, debug_warn,
|
||||
service::{appservice::RegistrationInfo, server_is_ours},
|
||||
services, Error, Result, Ruma,
|
||||
};
|
||||
|
||||
/// # `PUT /_matrix/client/v3/directory/room/{roomAlias}`
|
||||
|
@ -65,7 +66,6 @@ pub(crate) async fn create_alias_route(body: Ruma<create_alias::v3::Request>) ->
|
|||
/// - TODO: Update canonical alias event
|
||||
pub(crate) async fn delete_alias_route(body: Ruma<delete_alias::v3::Request>) -> Result<delete_alias::v3::Response> {
|
||||
alias_checks(&body.room_alias, &body.appservice_info).await?;
|
||||
|
||||
if services()
|
||||
.rooms
|
||||
.alias
|
||||
|
@ -99,7 +99,7 @@ pub(crate) async fn get_alias_route(body: Ruma<get_alias::v3::Request>) -> Resul
|
|||
get_alias_helper(body.body.room_alias, None).await
|
||||
}
|
||||
|
||||
pub(crate) async fn get_alias_helper(
|
||||
pub async fn get_alias_helper(
|
||||
room_alias: OwnedRoomAliasId, servers: Option<Vec<OwnedServerName>>,
|
||||
) -> Result<get_alias::v3::Response> {
|
||||
debug!("get_alias_helper servers: {servers:?}");
|
||||
|
|
|
@ -24,7 +24,7 @@ use ruma::{
|
|||
};
|
||||
use tracing::{error, info, warn};
|
||||
|
||||
use crate::{services, utils::server_name::server_is_ours, Error, Result, Ruma};
|
||||
use crate::{service::server_is_ours, services, Error, Result, Ruma};
|
||||
|
||||
/// # `POST /_matrix/client/v3/publicRooms`
|
||||
///
|
||||
|
|
|
@ -22,8 +22,9 @@ use tracing::debug;
|
|||
|
||||
use super::SESSION_ID_LENGTH;
|
||||
use crate::{
|
||||
service::user_is_local,
|
||||
services,
|
||||
utils::{self, user_id::user_is_local},
|
||||
utils::{self},
|
||||
Error, Result, Ruma,
|
||||
};
|
||||
|
||||
|
|
|
@ -15,14 +15,16 @@ use webpage::HTML;
|
|||
|
||||
use crate::{
|
||||
debug_warn,
|
||||
service::media::{FileMeta, UrlPreviewData},
|
||||
service::{
|
||||
media::{FileMeta, UrlPreviewData},
|
||||
server_is_ours,
|
||||
},
|
||||
services,
|
||||
utils::{
|
||||
self,
|
||||
content_disposition::{
|
||||
content_disposition_type, make_content_disposition, make_content_type, sanitise_filename,
|
||||
},
|
||||
server_name::server_is_ours,
|
||||
},
|
||||
Error, Result, Ruma, RumaResponse,
|
||||
};
|
||||
|
|
|
@ -35,9 +35,12 @@ use tracing::{debug, error, info, trace, warn};
|
|||
|
||||
use super::get_alias_helper;
|
||||
use crate::{
|
||||
service::pdu::{gen_event_id_canonical_json, PduBuilder},
|
||||
service::{
|
||||
pdu::{gen_event_id_canonical_json, PduBuilder},
|
||||
server_is_ours, user_is_local,
|
||||
},
|
||||
services,
|
||||
utils::{self, server_name::server_is_ours, user_id::user_is_local},
|
||||
utils::{self},
|
||||
Error, PduEvent, Result, Ruma,
|
||||
};
|
||||
|
||||
|
@ -607,7 +610,7 @@ pub(crate) async fn joined_members_route(
|
|||
})
|
||||
}
|
||||
|
||||
pub(crate) async fn join_room_by_id_helper(
|
||||
pub async fn join_room_by_id_helper(
|
||||
sender_user: Option<&UserId>, room_id: &RoomId, reason: Option<String>, servers: &[OwnedServerName],
|
||||
_third_party_signed: Option<&ThirdPartySigned>,
|
||||
) -> Result<join_room_by_id::v3::Response> {
|
||||
|
@ -1525,7 +1528,7 @@ pub(crate) async fn invite_helper(
|
|||
|
||||
// Make a user leave all their joined rooms, forgets all rooms, and ignores
|
||||
// errors
|
||||
pub(crate) async fn leave_all_rooms(user_id: &UserId) {
|
||||
pub async fn leave_all_rooms(user_id: &UserId) {
|
||||
let all_rooms = services()
|
||||
.rooms
|
||||
.state_cache
|
||||
|
@ -1550,7 +1553,7 @@ pub(crate) async fn leave_all_rooms(user_id: &UserId) {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn leave_room(user_id: &UserId, room_id: &RoomId, reason: Option<String>) -> Result<()> {
|
||||
pub async fn leave_room(user_id: &UserId, room_id: &RoomId, reason: Option<String>) -> Result<()> {
|
||||
// Ask a remote server if we don't have this room
|
||||
if !services()
|
||||
.rooms
|
||||
|
|
|
@ -3,6 +3,7 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
|
||||
use conduit::PduCount;
|
||||
use ruma::{
|
||||
api::client::{
|
||||
error::ErrorKind,
|
||||
|
@ -14,10 +15,7 @@ use ruma::{
|
|||
};
|
||||
use serde_json::{from_str, Value};
|
||||
|
||||
use crate::{
|
||||
service::{pdu::PduBuilder, rooms::timeline::PduCount},
|
||||
services, utils, Error, PduEvent, Result, Ruma,
|
||||
};
|
||||
use crate::{service::pdu::PduBuilder, services, utils, Error, PduEvent, Result, Ruma};
|
||||
|
||||
/// # `PUT /_matrix/client/v3/rooms/{roomId}/send/{eventType}/{txnId}`
|
||||
///
|
||||
|
|
|
@ -1,40 +1,41 @@
|
|||
mod account;
|
||||
mod alias;
|
||||
mod backup;
|
||||
mod capabilities;
|
||||
mod config;
|
||||
mod context;
|
||||
mod device;
|
||||
mod directory;
|
||||
mod filter;
|
||||
mod keys;
|
||||
mod media;
|
||||
mod membership;
|
||||
mod message;
|
||||
mod presence;
|
||||
mod profile;
|
||||
mod push;
|
||||
mod read_marker;
|
||||
mod redact;
|
||||
mod relations;
|
||||
mod report;
|
||||
mod room;
|
||||
mod search;
|
||||
mod session;
|
||||
mod space;
|
||||
mod state;
|
||||
mod sync;
|
||||
mod tag;
|
||||
mod thirdparty;
|
||||
mod threads;
|
||||
mod to_device;
|
||||
mod typing;
|
||||
mod unstable;
|
||||
mod unversioned;
|
||||
mod user_directory;
|
||||
mod voip;
|
||||
pub(crate) mod account;
|
||||
pub(crate) mod alias;
|
||||
pub(crate) mod backup;
|
||||
pub(crate) mod capabilities;
|
||||
pub(crate) mod config;
|
||||
pub(crate) mod context;
|
||||
pub(crate) mod device;
|
||||
pub(crate) mod directory;
|
||||
pub(crate) mod filter;
|
||||
pub(crate) mod keys;
|
||||
pub(crate) mod media;
|
||||
pub(crate) mod membership;
|
||||
pub(crate) mod message;
|
||||
pub(crate) mod presence;
|
||||
pub(crate) mod profile;
|
||||
pub(crate) mod push;
|
||||
pub(crate) mod read_marker;
|
||||
pub(crate) mod redact;
|
||||
pub(crate) mod relations;
|
||||
pub(crate) mod report;
|
||||
pub(crate) mod room;
|
||||
pub(crate) mod search;
|
||||
pub(crate) mod session;
|
||||
pub(crate) mod space;
|
||||
pub(crate) mod state;
|
||||
pub(crate) mod sync;
|
||||
pub(crate) mod tag;
|
||||
pub(crate) mod thirdparty;
|
||||
pub(crate) mod threads;
|
||||
pub(crate) mod to_device;
|
||||
pub(crate) mod typing;
|
||||
pub(crate) mod unstable;
|
||||
pub(crate) mod unversioned;
|
||||
pub(crate) mod user_directory;
|
||||
pub(crate) mod voip;
|
||||
|
||||
pub(crate) use account::*;
|
||||
pub use alias::get_alias_helper;
|
||||
pub(crate) use alias::*;
|
||||
pub(crate) use backup::*;
|
||||
pub(crate) use capabilities::*;
|
||||
|
@ -46,6 +47,7 @@ pub(crate) use filter::*;
|
|||
pub(crate) use keys::*;
|
||||
pub(crate) use media::*;
|
||||
pub(crate) use membership::*;
|
||||
pub use membership::{join_room_by_id_helper, leave_all_rooms, leave_room};
|
||||
pub(crate) use message::*;
|
||||
pub(crate) use presence::*;
|
||||
pub(crate) use profile::*;
|
||||
|
@ -77,7 +79,4 @@ const DEVICE_ID_LENGTH: usize = 10;
|
|||
const TOKEN_LENGTH: usize = 32;
|
||||
|
||||
/// generated user session ID length
|
||||
pub(crate) const SESSION_ID_LENGTH: usize = 32;
|
||||
|
||||
/// auto-generated password length
|
||||
pub(crate) const AUTO_GEN_PASSWORD_LENGTH: usize = 25;
|
||||
const SESSION_ID_LENGTH: usize = service::uiaa::SESSION_ID_LENGTH;
|
||||
|
|
|
@ -13,7 +13,10 @@ use ruma::{
|
|||
};
|
||||
use serde_json::value::to_raw_value;
|
||||
|
||||
use crate::{service::pdu::PduBuilder, services, utils::user_id::user_is_local, Error, Result, Ruma};
|
||||
use crate::{
|
||||
service::{pdu::PduBuilder, user_is_local},
|
||||
services, Error, Result, Ruma,
|
||||
};
|
||||
|
||||
/// # `PUT /_matrix/client/r0/profile/{userId}/displayname`
|
||||
///
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::collections::BTreeMap;
|
||||
|
||||
use conduit::PduCount;
|
||||
use ruma::{
|
||||
api::client::{error::ErrorKind, read_marker::set_read_marker, receipt::create_receipt},
|
||||
events::{
|
||||
|
@ -9,7 +10,7 @@ use ruma::{
|
|||
MilliSecondsSinceUnixEpoch,
|
||||
};
|
||||
|
||||
use crate::{service::rooms::timeline::PduCount, services, Error, Result, Ruma};
|
||||
use crate::{services, Error, Result, Ruma};
|
||||
|
||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/read_markers`
|
||||
///
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::{cmp::max, collections::BTreeMap, sync::Arc};
|
||||
|
||||
use conduit::{debug_info, debug_warn};
|
||||
use ruma::{
|
||||
api::client::{
|
||||
error::ErrorKind,
|
||||
|
@ -28,8 +29,7 @@ use serde_json::{json, value::to_raw_value};
|
|||
use tracing::{error, info, warn};
|
||||
|
||||
use crate::{
|
||||
api::client_server::invite_helper,
|
||||
debug_info, debug_warn,
|
||||
client_server::invite_helper,
|
||||
service::{appservice::RegistrationInfo, pdu::PduBuilder},
|
||||
services, Error, Result, Ruma,
|
||||
};
|
||||
|
|
|
@ -19,10 +19,8 @@ use ruma::{
|
|||
use tracing::{error, log::warn};
|
||||
|
||||
use crate::{
|
||||
service::{self, pdu::PduBuilder},
|
||||
services,
|
||||
utils::server_name::server_is_ours,
|
||||
Error, Result, Ruma, RumaResponse,
|
||||
service::{pdu::PduBuilder, server_is_ours},
|
||||
services, Error, Result, Ruma, RumaResponse,
|
||||
};
|
||||
|
||||
/// # `PUT /_matrix/client/*/rooms/{roomId}/state/{eventType}/{stateKey}`
|
||||
|
|
|
@ -5,6 +5,7 @@ use std::{
|
|||
time::Duration,
|
||||
};
|
||||
|
||||
use conduit::PduCount;
|
||||
use ruma::{
|
||||
api::client::{
|
||||
filter::{FilterDefinition, LazyLoadOptions},
|
||||
|
@ -29,10 +30,7 @@ use ruma::{
|
|||
};
|
||||
use tracing::{error, Instrument as _, Span};
|
||||
|
||||
use crate::{
|
||||
service::{pdu::EventHash, rooms::timeline::PduCount},
|
||||
services, utils, Error, PduEvent, Result, Ruma, RumaResponse,
|
||||
};
|
||||
use crate::{service::pdu::EventHash, services, utils, Error, PduEvent, Result, Ruma, RumaResponse};
|
||||
|
||||
/// # `GET /_matrix/client/r0/sync`
|
||||
///
|
||||
|
|
|
@ -8,7 +8,7 @@ use ruma::{
|
|||
to_device::DeviceIdOrAllDevices,
|
||||
};
|
||||
|
||||
use crate::{services, utils::user_id::user_is_local, Error, Result, Ruma};
|
||||
use crate::{services, user_is_local, Error, Result, Ruma};
|
||||
|
||||
/// # `PUT /_matrix/client/r0/sendToDevice/{eventType}/{txnId}`
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue