Move state_res from tuwunel_core to tuwunel_service.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
5
Cargo.lock
generated
5
Cargo.lock
generated
@@ -5417,16 +5417,19 @@ dependencies = [
|
|||||||
"blurhash",
|
"blurhash",
|
||||||
"bytes",
|
"bytes",
|
||||||
"const-str",
|
"const-str",
|
||||||
|
"criterion",
|
||||||
"ctor",
|
"ctor",
|
||||||
"futures",
|
"futures",
|
||||||
"hickory-resolver",
|
"hickory-resolver",
|
||||||
"http",
|
"http",
|
||||||
"image",
|
"image",
|
||||||
|
"insta",
|
||||||
"ipaddress",
|
"ipaddress",
|
||||||
"ldap3",
|
"ldap3",
|
||||||
"log",
|
"log",
|
||||||
"loole",
|
"loole",
|
||||||
"lru-cache",
|
"lru-cache",
|
||||||
|
"maplit",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest 0.13.1",
|
"reqwest 0.13.1",
|
||||||
@@ -5438,9 +5441,11 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
"sha2",
|
"sha2",
|
||||||
|
"similar",
|
||||||
"termimad",
|
"termimad",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
"tuwunel_core",
|
"tuwunel_core",
|
||||||
"tuwunel_database",
|
"tuwunel_database",
|
||||||
"url",
|
"url",
|
||||||
|
|||||||
@@ -116,7 +116,3 @@ similar.workspace = true
|
|||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[[bench]]
|
|
||||||
name = "state_res"
|
|
||||||
harness = false
|
|
||||||
|
|||||||
@@ -3,12 +3,10 @@
|
|||||||
pub mod event;
|
pub mod event;
|
||||||
pub mod pdu;
|
pub mod pdu;
|
||||||
pub mod room_version;
|
pub mod room_version;
|
||||||
pub mod state_res;
|
|
||||||
|
|
||||||
pub use event::{Event, StateKey, TypeExt as EventTypeExt, TypeStateKey, state_key};
|
pub use event::{Event, StateKey, TypeExt as EventTypeExt, TypeStateKey, state_key};
|
||||||
pub use pdu::{EventHash, Pdu, PduBuilder, PduCount, PduEvent, PduId, RawPduId};
|
pub use pdu::{EventHash, Pdu, PduBuilder, PduCount, PduEvent, PduId, RawPduId};
|
||||||
pub use room_version::{RoomVersion, RoomVersionRules};
|
pub use room_version::{RoomVersion, RoomVersionRules};
|
||||||
pub use state_res::{StateMap, events};
|
|
||||||
|
|
||||||
pub type ShortStateKey = ShortId;
|
pub type ShortStateKey = ShortId;
|
||||||
pub type ShortEventId = ShortId;
|
pub type ShortEventId = ShortId;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ pub use self::{
|
|||||||
Count as PduCount, Id as PduId, Pdu as PduEvent, RawId as RawPduId,
|
Count as PduCount, Id as PduId, Pdu as PduEvent, RawId as RawPduId,
|
||||||
builder::{Builder, Builder as PduBuilder},
|
builder::{Builder, Builder as PduBuilder},
|
||||||
count::Count,
|
count::Count,
|
||||||
|
format::check::check_pdu_format,
|
||||||
hashes::EventHashes as EventHash,
|
hashes::EventHashes as EventHash,
|
||||||
id::Id,
|
id::Id,
|
||||||
raw_id::*,
|
raw_id::*,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
pub(super) mod check;
|
||||||
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, CanonicalJsonValue, EventId, RoomId, RoomVersionId,
|
CanonicalJsonObject, CanonicalJsonValue, EventId, RoomId, RoomVersionId,
|
||||||
room_version_rules::{EventsReferenceFormatVersion, RoomVersionRules},
|
room_version_rules::{EventsReferenceFormatVersion, RoomVersionRules},
|
||||||
@@ -6,7 +8,6 @@ use ruma::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
Result, extract_variant, is_equal_to,
|
Result, extract_variant, is_equal_to,
|
||||||
matrix::{PduEvent, room_version},
|
matrix::{PduEvent, room_version},
|
||||||
state_res::{self},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn into_outgoing_federation(
|
pub fn into_outgoing_federation(
|
||||||
@@ -94,7 +95,7 @@ pub fn from_incoming_federation(
|
|||||||
pdu_json.insert("event_id".into(), CanonicalJsonValue::String(event_id.into()));
|
pdu_json.insert("event_id".into(), CanonicalJsonValue::String(event_id.into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
state_res::check_pdu_format(pdu_json, &room_rules.event_format)?;
|
check::check_pdu_format(pdu_json, &room_rules.event_format)?;
|
||||||
|
|
||||||
PduEvent::from_val(pdu_json)
|
PduEvent::from_val(pdu_json)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,7 @@ pub use ::tracing;
|
|||||||
pub use config::Config;
|
pub use config::Config;
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
pub use info::{rustc_flags_capture, version, version::version};
|
pub use info::{rustc_flags_capture, version, version::version};
|
||||||
pub use matrix::{
|
pub use matrix::{Event, EventTypeExt, Pdu, PduCount, PduEvent, PduId, RoomVersion, pdu};
|
||||||
Event, EventTypeExt, Pdu, PduCount, PduEvent, PduId, RoomVersion, pdu, state_res,
|
|
||||||
};
|
|
||||||
pub use server::Server;
|
pub use server::Server;
|
||||||
pub use utils::{ctor, dtor, implement, result, result::Result};
|
pub use utils::{ctor, dtor, implement, result, result::Result};
|
||||||
|
|
||||||
|
|||||||
@@ -126,5 +126,16 @@ blurhash.optional = true
|
|||||||
tuwunel-core.workspace = true
|
tuwunel-core.workspace = true
|
||||||
tuwunel-database.workspace = true
|
tuwunel-database.workspace = true
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
criterion.workspace = true
|
||||||
|
insta.workspace = true
|
||||||
|
maplit.workspace = true
|
||||||
|
similar.workspace = true
|
||||||
|
tracing-subscriber.workspace = true
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "state_res"
|
||||||
|
harness = false
|
||||||
|
|||||||
@@ -22,13 +22,10 @@ use serde_json::{
|
|||||||
};
|
};
|
||||||
use tuwunel_core::{
|
use tuwunel_core::{
|
||||||
Result, err,
|
Result, err,
|
||||||
matrix::{
|
matrix::{Event, EventHash, PduEvent, event::TypeExt},
|
||||||
Event, EventHash, PduEvent,
|
|
||||||
event::TypeExt,
|
|
||||||
state_res::{AuthSet, StateMap},
|
|
||||||
},
|
|
||||||
utils::stream::IterStream,
|
utils::stream::IterStream,
|
||||||
};
|
};
|
||||||
|
use tuwunel_service::rooms::state_res::{AuthSet, StateMap};
|
||||||
|
|
||||||
criterion_group!(
|
criterion_group!(
|
||||||
benches,
|
benches,
|
||||||
@@ -58,7 +55,7 @@ fn lexico_topo_sort(c: &mut Criterion) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
c.to_async(FuturesExecutor).iter(async || {
|
c.to_async(FuturesExecutor).iter(async || {
|
||||||
_ = tuwunel_core::matrix::state_res::topological_sort(&graph, &async |_id| {
|
_ = tuwunel_service::rooms::state_res::topological_sort(&graph, &async |_id| {
|
||||||
Ok((int!(0).into(), MilliSecondsSinceUnixEpoch(uint!(0))))
|
Ok((int!(0).into(), MilliSecondsSinceUnixEpoch(uint!(0))))
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
@@ -86,7 +83,7 @@ fn resolution_shallow_auth_chain(c: &mut Criterion) {
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let func = async || {
|
let func = async || {
|
||||||
if let Err(e) = tuwunel_core::matrix::state_res::resolve(
|
if let Err(e) = tuwunel_service::rooms::state_res::resolve(
|
||||||
&rules,
|
&rules,
|
||||||
state_sets.clone().into_iter().stream(),
|
state_sets.clone().into_iter().stream(),
|
||||||
auth_chains.clone().into_iter().stream(),
|
auth_chains.clone().into_iter().stream(),
|
||||||
@@ -169,7 +166,7 @@ fn resolve_deeper_event_set(c: &mut Criterion) {
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let func = async || {
|
let func = async || {
|
||||||
if let Err(e) = tuwunel_core::matrix::state_res::resolve(
|
if let Err(e) = tuwunel_service::rooms::state_res::resolve(
|
||||||
&rules,
|
&rules,
|
||||||
state_sets.clone().into_iter().stream(),
|
state_sets.clone().into_iter().stream(),
|
||||||
auth_chains.clone().into_iter().stream(),
|
auth_chains.clone().into_iter().stream(),
|
||||||
@@ -29,8 +29,8 @@ use serde_json::value::RawValue as RawJsonValue;
|
|||||||
use tuwunel_core::{
|
use tuwunel_core::{
|
||||||
Err, Result, at, debug, debug_error, debug_info, debug_warn, err, error, implement, info,
|
Err, Result, at, debug, debug_error, debug_info, debug_warn, err, error, implement, info,
|
||||||
matrix::{event::gen_event_id_canonical_json, room_version},
|
matrix::{event::gen_event_id_canonical_json, room_version},
|
||||||
pdu::{PduBuilder, format::from_incoming_federation},
|
pdu::{PduBuilder, check_pdu_format, format::from_incoming_federation},
|
||||||
state_res, trace,
|
trace,
|
||||||
utils::{self, BoolExt, IterStream, ReadyExt, future::TryExtExt, math::Expected, shuffle},
|
utils::{self, BoolExt, IterStream, ReadyExt, future::TryExtExt, math::Expected, shuffle},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
@@ -41,6 +41,7 @@ use crate::{
|
|||||||
rooms::{
|
rooms::{
|
||||||
state::RoomMutexGuard,
|
state::RoomMutexGuard,
|
||||||
state_compressor::{CompressedState, HashSetCompressStateEvent},
|
state_compressor::{CompressedState, HashSetCompressStateEvent},
|
||||||
|
state_res,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -756,7 +757,7 @@ async fn create_join_event(
|
|||||||
.server_keys
|
.server_keys
|
||||||
.gen_id_hash_and_sign_event(&mut event, room_version_id)?;
|
.gen_id_hash_and_sign_event(&mut event, room_version_id)?;
|
||||||
|
|
||||||
state_res::check_pdu_format(&event, &room_version_rules.event_format)?;
|
check_pdu_format(&event, &room_version_rules.event_format)?;
|
||||||
|
|
||||||
Ok((event, event_id, join_authorized_via_users_server))
|
Ok((event, event_id, join_authorized_via_users_server))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,8 @@ use ruma::{
|
|||||||
};
|
};
|
||||||
use tuwunel_core::{
|
use tuwunel_core::{
|
||||||
Err, Result, debug_info, debug_warn, err, implement,
|
Err, Result, debug_info, debug_warn, err, implement,
|
||||||
matrix::{PduCount, room_version},
|
matrix::{PduCount, pdu::check_pdu_format, room_version},
|
||||||
pdu::PduBuilder,
|
pdu::PduBuilder,
|
||||||
state_res,
|
|
||||||
utils::{
|
utils::{
|
||||||
self, FutureBoolExt,
|
self, FutureBoolExt,
|
||||||
future::{ReadyBoolExt, TryExtExt},
|
future::{ReadyBoolExt, TryExtExt},
|
||||||
@@ -354,7 +353,7 @@ async fn remote_leave(
|
|||||||
.server_keys
|
.server_keys
|
||||||
.gen_id_hash_and_sign_event(&mut event, &room_version_id)?;
|
.gen_id_hash_and_sign_event(&mut event, &room_version_id)?;
|
||||||
|
|
||||||
state_res::check_pdu_format(&event, &room_version_rules.event_format)?;
|
check_pdu_format(&event, &room_version_rules.event_format)?;
|
||||||
|
|
||||||
self.services
|
self.services
|
||||||
.federation
|
.federation
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ use ruma::{
|
|||||||
use tuwunel_core::{
|
use tuwunel_core::{
|
||||||
Result, debug_warn, err, implement,
|
Result, debug_warn, err, implement,
|
||||||
matrix::{Event, PduEvent},
|
matrix::{Event, PduEvent},
|
||||||
state_res::{self},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::check_room_id;
|
use super::check_room_id;
|
||||||
|
use crate::rooms::state_res;
|
||||||
|
|
||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
#[tracing::instrument(
|
#[tracing::instrument(
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ use ruma::{
|
|||||||
use tuwunel_core::{
|
use tuwunel_core::{
|
||||||
Err, Result, debug, debug_info, err, implement,
|
Err, Result, debug, debug_info, err, implement,
|
||||||
matrix::{Event, PduEvent, event::TypeExt, room_version},
|
matrix::{Event, PduEvent, event::TypeExt, room_version},
|
||||||
pdu::format::from_incoming_federation,
|
pdu::{check_pdu_format, format::from_incoming_federation},
|
||||||
ref_at, state_res, trace,
|
ref_at, trace,
|
||||||
utils::{future::TryExtExt, stream::IterStream},
|
utils::{future::TryExtExt, stream::IterStream},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::check_room_id;
|
use super::check_room_id;
|
||||||
|
use crate::rooms::state_res;
|
||||||
|
|
||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
pub(super) async fn handle_outlier_pdu(
|
pub(super) async fn handle_outlier_pdu(
|
||||||
@@ -70,7 +71,7 @@ pub(super) async fn handle_outlier_pdu(
|
|||||||
|
|
||||||
let room_rules = room_version::rules(room_version)?;
|
let room_rules = room_version::rules(room_version)?;
|
||||||
|
|
||||||
state_res::check_pdu_format(&pdu_json, &room_rules.event_format)?;
|
check_pdu_format(&pdu_json, &room_rules.event_format)?;
|
||||||
|
|
||||||
// Now that we have checked the signature and hashes we can make mutations and
|
// Now that we have checked the signature and hashes we can make mutations and
|
||||||
// convert to our PduEvent type.
|
// convert to our PduEvent type.
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ use ruma::{OwnedEventId, RoomId, RoomVersionId};
|
|||||||
use tuwunel_core::{
|
use tuwunel_core::{
|
||||||
Result, err, implement,
|
Result, err, implement,
|
||||||
matrix::room_version,
|
matrix::room_version,
|
||||||
state_res::{self, AuthSet, StateMap},
|
|
||||||
trace,
|
trace,
|
||||||
utils::stream::{IterStream, ReadyExt, TryWidebandExt, WidebandExt},
|
utils::stream::{IterStream, ReadyExt, TryWidebandExt, WidebandExt},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::rooms::state_compressor::CompressedState;
|
use crate::rooms::{
|
||||||
|
state_compressor::CompressedState,
|
||||||
|
state_res::{self, AuthSet, StateMap},
|
||||||
|
};
|
||||||
|
|
||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
#[tracing::instrument(
|
#[tracing::instrument(
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, future::try_join
|
|||||||
use ruma::{OwnedEventId, RoomId, RoomVersionId};
|
use ruma::{OwnedEventId, RoomId, RoomVersionId};
|
||||||
use tuwunel_core::{
|
use tuwunel_core::{
|
||||||
Result, apply, debug, debug_warn, err, implement,
|
Result, apply, debug, debug_warn, err, implement,
|
||||||
matrix::{Event, StateMap, state_res::AuthSet},
|
matrix::Event,
|
||||||
ref_at, trace,
|
ref_at, trace,
|
||||||
utils::{
|
utils::{
|
||||||
option::OptionExt,
|
option::OptionExt,
|
||||||
@@ -12,7 +12,10 @@ use tuwunel_core::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::rooms::short::ShortStateHash;
|
use crate::rooms::{
|
||||||
|
short::ShortStateHash,
|
||||||
|
state_res::{AuthSet, StateMap},
|
||||||
|
};
|
||||||
|
|
||||||
// TODO: if we know the prev_events of the incoming event we can avoid the
|
// TODO: if we know the prev_events of the incoming event we can avoid the
|
||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use ruma::{
|
|||||||
};
|
};
|
||||||
use tuwunel_core::{
|
use tuwunel_core::{
|
||||||
Err, Result, debug, debug_info, err, implement, is_equal_to,
|
Err, Result, debug, debug_info, err, implement, is_equal_to,
|
||||||
matrix::{Event, EventTypeExt, PduEvent, StateKey, room_version, state_res},
|
matrix::{Event, EventTypeExt, PduEvent, StateKey, pdu::check_pdu_format, room_version},
|
||||||
trace,
|
trace,
|
||||||
utils::stream::{BroadbandExt, ReadyExt},
|
utils::stream::{BroadbandExt, ReadyExt},
|
||||||
warn,
|
warn,
|
||||||
@@ -15,6 +15,7 @@ use tuwunel_core::{
|
|||||||
|
|
||||||
use crate::rooms::{
|
use crate::rooms::{
|
||||||
state_compressor::{CompressedState, HashSetCompressStateEvent},
|
state_compressor::{CompressedState, HashSetCompressStateEvent},
|
||||||
|
state_res,
|
||||||
timeline::RawPduId,
|
timeline::RawPduId,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -60,7 +61,7 @@ pub(super) async fn upgrade_outlier_to_timeline_pdu(
|
|||||||
let room_rules = room_version::rules(room_version)?;
|
let room_rules = room_version::rules(room_version)?;
|
||||||
|
|
||||||
trace!(format = ?room_rules.event_format, "Checking format");
|
trace!(format = ?room_rules.event_format, "Checking format");
|
||||||
state_res::check_pdu_format(&val, &room_rules.event_format)?;
|
check_pdu_format(&val, &room_rules.event_format)?;
|
||||||
|
|
||||||
// 10. Fetch missing state and auth chain events by calling /state_ids at
|
// 10. Fetch missing state and auth chain events by calling /state_ids at
|
||||||
// backwards extremities doing all the checks in this list starting at 1.
|
// backwards extremities doing all the checks in this list starting at 1.
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ pub mod state;
|
|||||||
pub mod state_accessor;
|
pub mod state_accessor;
|
||||||
pub mod state_cache;
|
pub mod state_cache;
|
||||||
pub mod state_compressor;
|
pub mod state_compressor;
|
||||||
|
pub mod state_res;
|
||||||
pub mod threads;
|
pub mod threads;
|
||||||
pub mod timeline;
|
pub mod timeline;
|
||||||
pub mod typing;
|
pub mod typing;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ use tuwunel_core::{
|
|||||||
implement,
|
implement,
|
||||||
matrix::{PduCount, RoomVersionRules, StateKey, TypeStateKey, room_version},
|
matrix::{PduCount, RoomVersionRules, StateKey, TypeStateKey, room_version},
|
||||||
result::{AndThenRef, FlatOk},
|
result::{AndThenRef, FlatOk},
|
||||||
state_res::{StateMap, auth_types_for_event},
|
|
||||||
trace,
|
trace,
|
||||||
utils::{
|
utils::{
|
||||||
IterStream, MutexMap, MutexMapGuard, ReadyExt, calculate_hash,
|
IterStream, MutexMap, MutexMapGuard, ReadyExt, calculate_hash,
|
||||||
@@ -29,6 +28,7 @@ use crate::{
|
|||||||
rooms::{
|
rooms::{
|
||||||
short::{ShortEventId, ShortStateHash, ShortStateKey},
|
short::{ShortEventId, ShortStateHash, ShortStateKey},
|
||||||
state_compressor::{CompressedState, parse_compressed_state_event},
|
state_compressor::{CompressedState, parse_compressed_state_event},
|
||||||
|
state_res::{StateMap, auth_types_for_event},
|
||||||
},
|
},
|
||||||
services::OnceServices,
|
services::OnceServices,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,10 +29,12 @@ use ruma::{
|
|||||||
};
|
};
|
||||||
use tuwunel_core::{
|
use tuwunel_core::{
|
||||||
Result, err, is_true,
|
Result, err, is_true,
|
||||||
matrix::{Pdu, room_version, state_res::events::RoomCreateEvent},
|
matrix::{Pdu, room_version},
|
||||||
utils::BoolExt,
|
utils::BoolExt,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::rooms::state_res::events::RoomCreateEvent;
|
||||||
|
|
||||||
pub struct Service {
|
pub struct Service {
|
||||||
services: Arc<crate::services::OnceServices>,
|
services: Arc<crate::services::OnceServices>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ use ruma::{
|
|||||||
},
|
},
|
||||||
room_version_rules::{AuthorizationRules, RoomVersionRules},
|
room_version_rules::{AuthorizationRules, RoomVersionRules},
|
||||||
};
|
};
|
||||||
|
use tuwunel_core::{
|
||||||
|
Err, Error, Result, err,
|
||||||
|
matrix::{Event, StateKey},
|
||||||
|
trace,
|
||||||
|
utils::stream::{IterStream, TryReadyExt},
|
||||||
|
};
|
||||||
|
|
||||||
pub use self::auth_types::{AuthTypes, auth_types_for_event};
|
pub use self::auth_types::{AuthTypes, auth_types_for_event};
|
||||||
use self::room_member::check_room_member;
|
use self::room_member::check_room_member;
|
||||||
@@ -28,12 +34,6 @@ use super::{
|
|||||||
power_levels::{self, RoomPowerLevelsEventOptionExt, RoomPowerLevelsIntField},
|
power_levels::{self, RoomPowerLevelsEventOptionExt, RoomPowerLevelsIntField},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::{
|
|
||||||
Err, Error, Result, err,
|
|
||||||
matrix::{Event, StateKey},
|
|
||||||
trace,
|
|
||||||
utils::stream::{IterStream, TryReadyExt},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[tracing::instrument(
|
#[tracing::instrument(
|
||||||
level = "debug",
|
level = "debug",
|
||||||
@@ -4,9 +4,9 @@ use ruma::{
|
|||||||
room_version_rules::AuthorizationRules,
|
room_version_rules::AuthorizationRules,
|
||||||
};
|
};
|
||||||
use serde_json::value::RawValue as RawJsonValue;
|
use serde_json::value::RawValue as RawJsonValue;
|
||||||
|
use tuwunel_core::{Err, Result, arrayvec::ArrayVec, matrix::pdu::MAX_AUTH_EVENTS};
|
||||||
|
|
||||||
use super::super::{TypeStateKey, events::member::RoomMemberEventContent};
|
use super::super::{TypeStateKey, events::member::RoomMemberEventContent};
|
||||||
use crate::{Err, Result, arrayvec::ArrayVec, matrix::pdu::MAX_AUTH_EVENTS};
|
|
||||||
|
|
||||||
pub type AuthTypes = ArrayVec<TypeStateKey, MAX_AUTH_EVENTS>;
|
pub type AuthTypes = ArrayVec<TypeStateKey, MAX_AUTH_EVENTS>;
|
||||||
|
|
||||||
@@ -8,8 +8,7 @@ use ruma::{
|
|||||||
serde::{Base64, base64::Standard},
|
serde::{Base64, base64::Standard},
|
||||||
signatures::verify_canonical_json_bytes,
|
signatures::verify_canonical_json_bytes,
|
||||||
};
|
};
|
||||||
|
use tuwunel_core::{
|
||||||
use crate::{
|
|
||||||
Err, Result, err, is_equal_to,
|
Err, Result, err, is_equal_to,
|
||||||
matrix::{Event, StateKey},
|
matrix::{Event, StateKey},
|
||||||
};
|
};
|
||||||
@@ -14,6 +14,8 @@ use serde_json::{json, value::to_raw_value as to_raw_json_value};
|
|||||||
|
|
||||||
mod room_power_levels;
|
mod room_power_levels;
|
||||||
|
|
||||||
|
use tuwunel_core::matrix::{EventHash, PduEvent, StateKey};
|
||||||
|
|
||||||
use self::room_power_levels::default_room_power_levels;
|
use self::room_power_levels::default_room_power_levels;
|
||||||
use super::{
|
use super::{
|
||||||
check_room_create, check_room_redaction, check_state_dependent_auth_rules,
|
check_room_create, check_room_redaction, check_state_dependent_auth_rules,
|
||||||
@@ -26,7 +28,6 @@ use super::{
|
|||||||
to_pdu_event,
|
to_pdu_event,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::matrix::{EventHash, PduEvent, StateKey};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn valid_room_create() {
|
fn valid_room_create() {
|
||||||
@@ -674,7 +675,7 @@ async fn auth_event_in_different_room() {
|
|||||||
depth: uint!(0),
|
depth: uint!(0),
|
||||||
hashes: EventHash::default(),
|
hashes: EventHash::default(),
|
||||||
signatures: None,
|
signatures: None,
|
||||||
rejected: false,
|
//rejected: false,
|
||||||
};
|
};
|
||||||
init_events
|
init_events
|
||||||
.insert(power_level.event_id.clone(), power_level)
|
.insert(power_level.event_id.clone(), power_level)
|
||||||
@@ -782,6 +783,7 @@ async fn unexpected_auth_event_type() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[ignore = "PduEvent::rejected not conditionally compiled here"]
|
||||||
async fn rejected_auth_event() {
|
async fn rejected_auth_event() {
|
||||||
let _guard = init_subscriber();
|
let _guard = init_subscriber();
|
||||||
|
|
||||||
@@ -812,7 +814,7 @@ async fn rejected_auth_event() {
|
|||||||
depth: uint!(0),
|
depth: uint!(0),
|
||||||
hashes: EventHash::default(),
|
hashes: EventHash::default(),
|
||||||
signatures: None,
|
signatures: None,
|
||||||
rejected: true,
|
//rejected: true,
|
||||||
};
|
};
|
||||||
init_events
|
init_events
|
||||||
.insert(power_level.event_id.clone(), power_level)
|
.insert(power_level.event_id.clone(), power_level)
|
||||||
@@ -903,7 +905,7 @@ async fn event_without_room_id() {
|
|||||||
depth: uint!(0),
|
depth: uint!(0),
|
||||||
hashes: EventHash::default(),
|
hashes: EventHash::default(),
|
||||||
signatures: None,
|
signatures: None,
|
||||||
rejected: false,
|
//rejected: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let init_events = INITIAL_HYDRA_EVENTS();
|
let init_events = INITIAL_HYDRA_EVENTS();
|
||||||
@@ -1020,6 +1022,7 @@ async fn missing_room_create_in_fetch_event() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[ignore = "PduEvent::rejected not conditionally compiled here"]
|
||||||
async fn rejected_room_create_in_fetch_event() {
|
async fn rejected_room_create_in_fetch_event() {
|
||||||
let _guard = init_subscriber();
|
let _guard = init_subscriber();
|
||||||
|
|
||||||
@@ -1035,8 +1038,8 @@ async fn rejected_room_create_in_fetch_event() {
|
|||||||
|
|
||||||
let mut init_events = INITIAL_HYDRA_EVENTS();
|
let mut init_events = INITIAL_HYDRA_EVENTS();
|
||||||
let create_event_id = owned_event_id!("$CREATE");
|
let create_event_id = owned_event_id!("$CREATE");
|
||||||
let mut create_event = init_events.remove(&create_event_id).unwrap();
|
let create_event = init_events.remove(&create_event_id).unwrap();
|
||||||
create_event.rejected = true;
|
//create_event.rejected = true;
|
||||||
init_events.insert(create_event_id, create_event);
|
init_events.insert(create_event_id, create_event);
|
||||||
|
|
||||||
// Reject event if `m.room.create` was rejected.
|
// Reject event if `m.room.create` was rejected.
|
||||||
@@ -9,16 +9,13 @@ use serde_json::{
|
|||||||
Value as JsonValue, json,
|
Value as JsonValue, json,
|
||||||
value::{Map as JsonMap, to_raw_value as to_raw_json_value},
|
value::{Map as JsonMap, to_raw_value as to_raw_json_value},
|
||||||
};
|
};
|
||||||
|
use tuwunel_core::{extract_variant, info, matrix::PduEvent};
|
||||||
|
|
||||||
use super::{
|
use super::super::{
|
||||||
super::{
|
check_room_power_levels,
|
||||||
check_room_power_levels,
|
events::RoomPowerLevelsEvent,
|
||||||
events::RoomPowerLevelsEvent,
|
test_utils::{alice, bob, init_subscriber, to_pdu_event, zara},
|
||||||
test_utils::{alice, bob, init_subscriber, to_pdu_event, zara},
|
|
||||||
},
|
|
||||||
PduEvent,
|
|
||||||
};
|
};
|
||||||
use crate::{extract_variant, info};
|
|
||||||
|
|
||||||
/// The default `m.room.power_levels` event when creating a public room.
|
/// The default `m.room.power_levels` event when creating a public room.
|
||||||
pub(super) fn default_room_power_levels() -> RoomPowerLevelsEvent<PduEvent> {
|
pub(super) fn default_room_power_levels() -> RoomPowerLevelsEvent<PduEvent> {
|
||||||
@@ -27,7 +27,7 @@ pub use self::{
|
|||||||
/// > that might remove someone’s ability to do something in the room.
|
/// > that might remove someone’s ability to do something in the room.
|
||||||
pub(super) fn is_power_event<Pdu>(event: &Pdu) -> bool
|
pub(super) fn is_power_event<Pdu>(event: &Pdu) -> bool
|
||||||
where
|
where
|
||||||
Pdu: crate::matrix::Event,
|
Pdu: tuwunel_core::matrix::Event,
|
||||||
{
|
{
|
||||||
use ruma::events::{TimelineEventType, room::member::MembershipState};
|
use ruma::events::{TimelineEventType, room::member::MembershipState};
|
||||||
|
|
||||||
@@ -7,8 +7,7 @@ use ruma::{
|
|||||||
serde::from_raw_json_value,
|
serde::from_raw_json_value,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, de::IgnoredAny};
|
use serde::{Deserialize, de::IgnoredAny};
|
||||||
|
use tuwunel_core::{Error, Result, err, matrix::Event};
|
||||||
use crate::{Error, Result, err, matrix::Event};
|
|
||||||
|
|
||||||
/// A helper type for an [`Event`] of type `m.room.create`.
|
/// A helper type for an [`Event`] of type `m.room.create`.
|
||||||
///
|
///
|
||||||
@@ -4,8 +4,7 @@ use std::ops::Deref;
|
|||||||
|
|
||||||
use ruma::serde::{PartialEqAsRefStr, StringEnum, from_raw_json_value};
|
use ruma::serde::{PartialEqAsRefStr, StringEnum, from_raw_json_value};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use tuwunel_core::{Error, Result, err, matrix::Event};
|
||||||
use crate::{Error, Result, err, matrix::Event};
|
|
||||||
|
|
||||||
/// A helper type for an [`Event`] of type `m.room.join_rules`.
|
/// A helper type for an [`Event`] of type `m.room.join_rules`.
|
||||||
///
|
///
|
||||||
@@ -8,8 +8,7 @@ use ruma::{
|
|||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::value::RawValue as RawJsonValue;
|
use serde_json::value::RawValue as RawJsonValue;
|
||||||
|
use tuwunel_core::{Err, Error, Result, debug_error, err, matrix::Event};
|
||||||
use crate::{Err, Error, Result, debug_error, err, matrix::Event};
|
|
||||||
|
|
||||||
/// A helper type for an [`Event`] of type `m.room.member`.
|
/// A helper type for an [`Event`] of type `m.room.member`.
|
||||||
///
|
///
|
||||||
@@ -15,8 +15,7 @@ use ruma::{
|
|||||||
};
|
};
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde_json::{Error, from_value as from_json_value};
|
use serde_json::{Error, from_value as from_json_value};
|
||||||
|
use tuwunel_core::{Result, err, is_equal_to, matrix::Event, ref_at};
|
||||||
use crate::{Result, err, is_equal_to, matrix::Event, ref_at};
|
|
||||||
|
|
||||||
/// The default value of the creator's power level.
|
/// The default value of the creator's power level.
|
||||||
const DEFAULT_CREATOR_POWER_LEVEL: i32 = 100;
|
const DEFAULT_CREATOR_POWER_LEVEL: i32 = 100;
|
||||||
@@ -4,8 +4,7 @@ use std::{collections::BTreeSet, ops::Deref};
|
|||||||
|
|
||||||
use ruma::{serde::from_raw_json_value, third_party_invite::IdentityServerBase64PublicKey};
|
use ruma::{serde::from_raw_json_value, third_party_invite::IdentityServerBase64PublicKey};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use tuwunel_core::{Error, Result, err, matrix::Event};
|
||||||
use crate::{Error, Result, err, matrix::Event};
|
|
||||||
|
|
||||||
/// A helper type for an [`Event`] of type `m.room.third_party_invite`.
|
/// A helper type for an [`Event`] of type `m.room.third_party_invite`.
|
||||||
///
|
///
|
||||||
@@ -2,15 +2,15 @@ use ruma::{
|
|||||||
UserId,
|
UserId,
|
||||||
events::{StateEventType, room::member::MembershipState},
|
events::{StateEventType, room::member::MembershipState},
|
||||||
};
|
};
|
||||||
|
use tuwunel_core::{
|
||||||
|
Result, err,
|
||||||
|
matrix::{Event, StateKey},
|
||||||
|
};
|
||||||
|
|
||||||
use super::events::{
|
use super::events::{
|
||||||
JoinRule, RoomCreateEvent, RoomJoinRulesEvent, RoomMemberEvent, RoomPowerLevelsEvent,
|
JoinRule, RoomCreateEvent, RoomJoinRulesEvent, RoomMemberEvent, RoomPowerLevelsEvent,
|
||||||
RoomThirdPartyInviteEvent, member::RoomMemberEventResultExt,
|
RoomThirdPartyInviteEvent, member::RoomMemberEventResultExt,
|
||||||
};
|
};
|
||||||
use crate::{
|
|
||||||
Result, err,
|
|
||||||
matrix::{Event, StateKey},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub(super) trait FetchStateExt<Pdu: Event> {
|
pub(super) trait FetchStateExt<Pdu: Event> {
|
||||||
async fn room_create_event(&self) -> Result<RoomCreateEvent<Pdu>>;
|
async fn room_create_event(&self) -> Result<RoomCreateEvent<Pdu>>;
|
||||||
@@ -59,7 +59,6 @@
|
|||||||
//! [ruma-events]: https://crates.io/crates/ruma-events
|
//! [ruma-events]: https://crates.io/crates/ruma-events
|
||||||
|
|
||||||
mod event_auth;
|
mod event_auth;
|
||||||
mod event_format;
|
|
||||||
pub mod events;
|
pub mod events;
|
||||||
mod fetch_state;
|
mod fetch_state;
|
||||||
mod resolve;
|
mod resolve;
|
||||||
@@ -67,11 +66,11 @@ mod resolve;
|
|||||||
mod test_utils;
|
mod test_utils;
|
||||||
pub mod topological_sort;
|
pub mod topological_sort;
|
||||||
|
|
||||||
|
use tuwunel_core::matrix::TypeStateKey;
|
||||||
|
|
||||||
use self::{event_auth::check_state_dependent_auth_rules, fetch_state::FetchStateExt};
|
use self::{event_auth::check_state_dependent_auth_rules, fetch_state::FetchStateExt};
|
||||||
pub use self::{
|
pub use self::{
|
||||||
event_auth::{AuthTypes, auth_check, auth_types_for_event},
|
event_auth::{AuthTypes, auth_check, auth_types_for_event},
|
||||||
event_format::check_pdu_format,
|
|
||||||
resolve::{AuthSet, ConflictMap, StateMap, resolve},
|
resolve::{AuthSet, ConflictMap, StateMap, resolve},
|
||||||
topological_sort::topological_sort,
|
topological_sort::topological_sort,
|
||||||
};
|
};
|
||||||
use crate::matrix::TypeStateKey;
|
|
||||||
@@ -14,18 +14,10 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use futures::{FutureExt, Stream, StreamExt, TryFutureExt};
|
use futures::{FutureExt, Stream, StreamExt, TryFutureExt};
|
||||||
use itertools::Itertools;
|
|
||||||
use ruma::{OwnedEventId, events::StateEventType, room_version_rules::RoomVersionRules};
|
use ruma::{OwnedEventId, events::StateEventType, room_version_rules::RoomVersionRules};
|
||||||
|
use tuwunel_core::{
|
||||||
use self::{
|
|
||||||
auth_difference::auth_difference, conflicted_subgraph::conflicted_subgraph_dfs,
|
|
||||||
iterative_auth_check::iterative_auth_check, mainline_sort::mainline_sort,
|
|
||||||
power_sort::power_sort, split_conflicted::split_conflicted_state,
|
|
||||||
};
|
|
||||||
#[cfg(test)]
|
|
||||||
use super::test_utils;
|
|
||||||
use crate::{
|
|
||||||
Result, debug,
|
Result, debug,
|
||||||
|
itertools::Itertools,
|
||||||
matrix::{Event, TypeStateKey},
|
matrix::{Event, TypeStateKey},
|
||||||
smallvec::SmallVec,
|
smallvec::SmallVec,
|
||||||
trace,
|
trace,
|
||||||
@@ -35,6 +27,14 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use self::{
|
||||||
|
auth_difference::auth_difference, conflicted_subgraph::conflicted_subgraph_dfs,
|
||||||
|
iterative_auth_check::iterative_auth_check, mainline_sort::mainline_sort,
|
||||||
|
power_sort::power_sort, split_conflicted::split_conflicted_state,
|
||||||
|
};
|
||||||
|
#[cfg(test)]
|
||||||
|
use super::test_utils;
|
||||||
|
|
||||||
/// A mapping of event type and state_key to some value `T`, usually an
|
/// A mapping of event type and state_key to some value `T`, usually an
|
||||||
/// `EventId`.
|
/// `EventId`.
|
||||||
pub type StateMap<Id> = BTreeMap<TypeStateKey, Id>;
|
pub type StateMap<Id> = BTreeMap<TypeStateKey, Id>;
|
||||||
@@ -2,9 +2,9 @@ use std::borrow::Borrow;
|
|||||||
|
|
||||||
use futures::{FutureExt, Stream};
|
use futures::{FutureExt, Stream};
|
||||||
use ruma::EventId;
|
use ruma::EventId;
|
||||||
|
use tuwunel_core::utils::stream::{IterStream, ReadyExt};
|
||||||
|
|
||||||
use super::AuthSet;
|
use super::AuthSet;
|
||||||
use crate::utils::stream::{IterStream, ReadyExt};
|
|
||||||
|
|
||||||
/// Get the auth difference for the given auth chains.
|
/// Get the auth difference for the given auth chains.
|
||||||
///
|
///
|
||||||
@@ -7,8 +7,7 @@ use std::{
|
|||||||
|
|
||||||
use futures::{Future, FutureExt, Stream, StreamExt};
|
use futures::{Future, FutureExt, Stream, StreamExt};
|
||||||
use ruma::OwnedEventId;
|
use ruma::OwnedEventId;
|
||||||
|
use tuwunel_core::{
|
||||||
use crate::{
|
|
||||||
Result, debug,
|
Result, debug,
|
||||||
matrix::{Event, pdu::AuthEvents},
|
matrix::{Event, pdu::AuthEvents},
|
||||||
smallvec::SmallVec,
|
smallvec::SmallVec,
|
||||||
@@ -4,12 +4,7 @@ use ruma::{
|
|||||||
events::{StateEventType, TimelineEventType},
|
events::{StateEventType, TimelineEventType},
|
||||||
room_version_rules::RoomVersionRules,
|
room_version_rules::RoomVersionRules,
|
||||||
};
|
};
|
||||||
|
use tuwunel_core::{
|
||||||
use super::{
|
|
||||||
super::{auth_types_for_event, check_state_dependent_auth_rules},
|
|
||||||
StateMap,
|
|
||||||
};
|
|
||||||
use crate::{
|
|
||||||
Error, Result, debug_warn, err, error,
|
Error, Result, debug_warn, err, error,
|
||||||
matrix::{Event, EventTypeExt, StateKey},
|
matrix::{Event, EventTypeExt, StateKey},
|
||||||
smallvec::SmallVec,
|
smallvec::SmallVec,
|
||||||
@@ -17,6 +12,11 @@ use crate::{
|
|||||||
utils::stream::{IterStream, ReadyExt, TryReadyExt, TryWidebandExt},
|
utils::stream::{IterStream, ReadyExt, TryReadyExt, TryWidebandExt},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::{
|
||||||
|
super::{auth_types_for_event, check_state_dependent_auth_rules},
|
||||||
|
StateMap,
|
||||||
|
};
|
||||||
|
|
||||||
/// Perform the iterative auth checks to the given list of events.
|
/// Perform the iterative auth checks to the given list of events.
|
||||||
///
|
///
|
||||||
/// Definition in the specification:
|
/// Definition in the specification:
|
||||||
@@ -2,8 +2,7 @@ use futures::{
|
|||||||
FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt, pin_mut, stream::try_unfold,
|
FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt, pin_mut, stream::try_unfold,
|
||||||
};
|
};
|
||||||
use ruma::{EventId, OwnedEventId, events::TimelineEventType};
|
use ruma::{EventId, OwnedEventId, events::TimelineEventType};
|
||||||
|
use tuwunel_core::{
|
||||||
use crate::{
|
|
||||||
Error, Result, at, is_equal_to,
|
Error, Result, at, is_equal_to,
|
||||||
matrix::Event,
|
matrix::Event,
|
||||||
trace,
|
trace,
|
||||||
@@ -9,6 +9,11 @@ use ruma::{
|
|||||||
events::{TimelineEventType, room::power_levels::UserPowerLevel},
|
events::{TimelineEventType, room::power_levels::UserPowerLevel},
|
||||||
room_version_rules::RoomVersionRules,
|
room_version_rules::RoomVersionRules,
|
||||||
};
|
};
|
||||||
|
use tuwunel_core::{
|
||||||
|
Result, err,
|
||||||
|
matrix::Event,
|
||||||
|
utils::stream::{BroadbandExt, IterStream, TryBroadbandExt},
|
||||||
|
};
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
events::{
|
events::{
|
||||||
@@ -18,11 +23,6 @@ use super::super::{
|
|||||||
topological_sort,
|
topological_sort,
|
||||||
topological_sort::ReferencedIds,
|
topological_sort::ReferencedIds,
|
||||||
};
|
};
|
||||||
use crate::{
|
|
||||||
Result, err,
|
|
||||||
matrix::Event,
|
|
||||||
utils::stream::{BroadbandExt, IterStream, TryBroadbandExt},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Enlarge the given list of conflicted power events by adding the events in
|
/// Enlarge the given list of conflicted power events by adding the events in
|
||||||
/// their auth chain that are in the full conflicted set, and sort it using
|
/// their auth chain that are in the full conflicted set, and sort it using
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
use std::{collections::HashMap, hash::Hash, iter::IntoIterator};
|
use std::{collections::HashMap, hash::Hash, iter::IntoIterator};
|
||||||
|
|
||||||
use futures::{Stream, StreamExt};
|
use futures::{Stream, StreamExt};
|
||||||
|
use tuwunel_core::validated;
|
||||||
|
|
||||||
use super::{ConflictMap, StateMap};
|
use super::{ConflictMap, StateMap};
|
||||||
use crate::validated;
|
|
||||||
|
|
||||||
/// Split the unconflicted state map and the conflicted state set.
|
/// Split the unconflicted state map and the conflicted state set.
|
||||||
///
|
///
|
||||||
@@ -14,6 +14,11 @@ use ruma::{
|
|||||||
uint,
|
uint,
|
||||||
};
|
};
|
||||||
use serde_json::{json, value::to_raw_value as to_raw_json_value};
|
use serde_json::{json, value::to_raw_value as to_raw_json_value};
|
||||||
|
use tuwunel_core::{
|
||||||
|
debug,
|
||||||
|
matrix::{Event, EventTypeExt, PduEvent},
|
||||||
|
utils::stream::IterStream,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
StateMap,
|
StateMap,
|
||||||
@@ -23,11 +28,6 @@ use super::{
|
|||||||
to_pdu_event, zara,
|
to_pdu_event, zara,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::{
|
|
||||||
debug,
|
|
||||||
matrix::{Event, EventTypeExt, PduEvent},
|
|
||||||
utils::stream::IterStream,
|
|
||||||
};
|
|
||||||
|
|
||||||
async fn test_event_sort() {
|
async fn test_event_sort() {
|
||||||
_ = tracing::subscriber::set_default(
|
_ = tracing::subscriber::set_default(
|
||||||
@@ -26,17 +26,15 @@ use serde_json::{
|
|||||||
json,
|
json,
|
||||||
value::{RawValue as RawJsonValue, to_raw_value as to_raw_json_value},
|
value::{RawValue as RawJsonValue, to_raw_value as to_raw_json_value},
|
||||||
};
|
};
|
||||||
|
use tuwunel_core::{
|
||||||
use super::{AuthSet, StateMap, auth_types_for_event, events::RoomCreateEvent};
|
|
||||||
use crate::{
|
|
||||||
Error, Result, err, info,
|
Error, Result, err, info,
|
||||||
matrix::{
|
matrix::{Event, EventHash, EventTypeExt, PduEvent, StateKey},
|
||||||
Event, EventHash, EventTypeExt, PduEvent, StateKey,
|
|
||||||
state_res::topological_sort::ReferencedIds,
|
|
||||||
},
|
|
||||||
utils::stream::IterStream,
|
utils::stream::IterStream,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::{AuthSet, StateMap, auth_types_for_event, events::RoomCreateEvent};
|
||||||
|
use crate::rooms::state_res::topological_sort::ReferencedIds;
|
||||||
|
|
||||||
static SERVER_TIMESTAMP: AtomicU64 = AtomicU64::new(0);
|
static SERVER_TIMESTAMP: AtomicU64 = AtomicU64::new(0);
|
||||||
|
|
||||||
pub(super) fn not_found() -> Error { err!(Request(NotFound("Test event not found"))) }
|
pub(super) fn not_found() -> Error { err!(Request(NotFound("Test event not found"))) }
|
||||||
@@ -452,7 +450,7 @@ pub(super) fn to_init_pdu_event(
|
|||||||
depth: uint!(0),
|
depth: uint!(0),
|
||||||
hashes: EventHash::default(),
|
hashes: EventHash::default(),
|
||||||
signatures: None,
|
signatures: None,
|
||||||
rejected: false,
|
//rejected: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,7 +500,7 @@ where
|
|||||||
depth: uint!(0),
|
depth: uint!(0),
|
||||||
hashes: EventHash::default(),
|
hashes: EventHash::default(),
|
||||||
signatures: None,
|
signatures: None,
|
||||||
rejected: false,
|
//rejected: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,7 +555,7 @@ where
|
|||||||
depth: uint!(0),
|
depth: uint!(0),
|
||||||
hashes: EventHash::default(),
|
hashes: EventHash::default(),
|
||||||
signatures: None,
|
signatures: None,
|
||||||
rejected: false,
|
//rejected: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -605,7 +603,7 @@ where
|
|||||||
depth: uint!(0),
|
depth: uint!(0),
|
||||||
hashes: EventHash::default(),
|
hashes: EventHash::default(),
|
||||||
signatures: None,
|
signatures: None,
|
||||||
rejected: false,
|
//rejected: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,7 +640,7 @@ pub(super) fn room_create_hydra_pdu_event(
|
|||||||
depth: uint!(0),
|
depth: uint!(0),
|
||||||
hashes: EventHash::default(),
|
hashes: EventHash::default(),
|
||||||
signatures: None,
|
signatures: None,
|
||||||
rejected: false,
|
//rejected: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,8 +31,7 @@ use futures::TryStreamExt;
|
|||||||
use ruma::{
|
use ruma::{
|
||||||
MilliSecondsSinceUnixEpoch, OwnedEventId, events::room::power_levels::UserPowerLevel,
|
MilliSecondsSinceUnixEpoch, OwnedEventId, events::room::power_levels::UserPowerLevel,
|
||||||
};
|
};
|
||||||
|
use tuwunel_core::{
|
||||||
use crate::{
|
|
||||||
Error, Result, is_not_equal_to, smallvec::SmallVec, utils::stream::IterStream, validated,
|
Error, Result, is_not_equal_to, smallvec::SmallVec, utils::stream::IterStream, validated,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -13,9 +13,8 @@ use tuwunel_core::{
|
|||||||
Error, Result, err, implement,
|
Error, Result, err, implement,
|
||||||
matrix::{
|
matrix::{
|
||||||
event::{Event, StateKey, TypeExt},
|
event::{Event, StateKey, TypeExt},
|
||||||
pdu::{EventHash, PduBuilder, PduEvent, PrevEvents},
|
pdu::{EventHash, PduBuilder, PduEvent, PrevEvents, check_pdu_format},
|
||||||
room_version,
|
room_version,
|
||||||
state_res::{self},
|
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
IterStream, ReadyExt, TryReadyExt, millis_since_unix_epoch, stream::TryIgnore,
|
IterStream, ReadyExt, TryReadyExt, millis_since_unix_epoch, stream::TryIgnore,
|
||||||
@@ -24,6 +23,7 @@ use tuwunel_core::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::RoomMutexGuard;
|
use super::RoomMutexGuard;
|
||||||
|
use crate::rooms::state_res;
|
||||||
|
|
||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
pub async fn create_hash_and_sign_event(
|
pub async fn create_hash_and_sign_event(
|
||||||
@@ -195,7 +195,7 @@ pub async fn create_hash_and_sign_event(
|
|||||||
pdu_json.insert("room_id".into(), CanonicalJsonValue::String(pdu.room_id.clone().into()));
|
pdu_json.insert("room_id".into(), CanonicalJsonValue::String(pdu.room_id.clone().into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
state_res::check_pdu_format(&pdu_json, &version_rules.event_format)?;
|
check_pdu_format(&pdu_json, &version_rules.event_format)?;
|
||||||
|
|
||||||
// Generate short event id
|
// Generate short event id
|
||||||
let _shorteventid = self
|
let _shorteventid = self
|
||||||
|
|||||||
@@ -23,12 +23,10 @@ use similar::{Algorithm, udiff::unified_diff};
|
|||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
use tuwunel_core::{
|
use tuwunel_core::{
|
||||||
Result, err,
|
Result, err,
|
||||||
matrix::{
|
matrix::{Event, Pdu, StateKey},
|
||||||
Event, Pdu, StateKey, StateMap,
|
|
||||||
state_res::{AuthSet, resolve},
|
|
||||||
},
|
|
||||||
utils::stream::IterStream,
|
utils::stream::IterStream,
|
||||||
};
|
};
|
||||||
|
use tuwunel_service::rooms::state_res::{AuthSet, StateMap, resolve};
|
||||||
|
|
||||||
/// Create a new snapshot test.
|
/// Create a new snapshot test.
|
||||||
///
|
///
|
||||||
Reference in New Issue
Block a user