Move state_res from tuwunel_core to tuwunel_service.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2026-02-16 05:43:03 +00:00
parent 6a550baf5f
commit 9ede830ffe
73 changed files with 134 additions and 131 deletions

5
Cargo.lock generated
View File

@@ -5417,16 +5417,19 @@ dependencies = [
"blurhash",
"bytes",
"const-str",
"criterion",
"ctor",
"futures",
"hickory-resolver",
"http",
"image",
"insta",
"ipaddress",
"ldap3",
"log",
"loole",
"lru-cache",
"maplit",
"rand 0.8.5",
"regex",
"reqwest 0.13.1",
@@ -5438,9 +5441,11 @@ dependencies = [
"serde_json",
"serde_yaml",
"sha2",
"similar",
"termimad",
"tokio",
"tracing",
"tracing-subscriber",
"tuwunel_core",
"tuwunel_database",
"url",

View File

@@ -116,7 +116,3 @@ similar.workspace = true
[lints]
workspace = true
[[bench]]
name = "state_res"
harness = false

View File

@@ -3,12 +3,10 @@
pub mod event;
pub mod pdu;
pub mod room_version;
pub mod state_res;
pub use event::{Event, StateKey, TypeExt as EventTypeExt, TypeStateKey, state_key};
pub use pdu::{EventHash, Pdu, PduBuilder, PduCount, PduEvent, PduId, RawPduId};
pub use room_version::{RoomVersion, RoomVersionRules};
pub use state_res::{StateMap, events};
pub type ShortStateKey = ShortId;
pub type ShortEventId = ShortId;

View File

@@ -22,6 +22,7 @@ pub use self::{
Count as PduCount, Id as PduId, Pdu as PduEvent, RawId as RawPduId,
builder::{Builder, Builder as PduBuilder},
count::Count,
format::check::check_pdu_format,
hashes::EventHashes as EventHash,
id::Id,
raw_id::*,

View File

@@ -1,3 +1,5 @@
pub(super) mod check;
use ruma::{
CanonicalJsonObject, CanonicalJsonValue, EventId, RoomId, RoomVersionId,
room_version_rules::{EventsReferenceFormatVersion, RoomVersionRules},
@@ -6,7 +8,6 @@ use ruma::{
use crate::{
Result, extract_variant, is_equal_to,
matrix::{PduEvent, room_version},
state_res::{self},
};
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()));
}
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)
}

View File

@@ -25,9 +25,7 @@ pub use ::tracing;
pub use config::Config;
pub use error::Error;
pub use info::{rustc_flags_capture, version, version::version};
pub use matrix::{
Event, EventTypeExt, Pdu, PduCount, PduEvent, PduId, RoomVersion, pdu, state_res,
};
pub use matrix::{Event, EventTypeExt, Pdu, PduCount, PduEvent, PduId, RoomVersion, pdu};
pub use server::Server;
pub use utils::{ctor, dtor, implement, result, result::Result};

View File

@@ -126,5 +126,16 @@ blurhash.optional = true
tuwunel-core.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]
workspace = true
[[bench]]
name = "state_res"
harness = false

View File

@@ -22,13 +22,10 @@ use serde_json::{
};
use tuwunel_core::{
Result, err,
matrix::{
Event, EventHash, PduEvent,
event::TypeExt,
state_res::{AuthSet, StateMap},
},
matrix::{Event, EventHash, PduEvent, event::TypeExt},
utils::stream::IterStream,
};
use tuwunel_service::rooms::state_res::{AuthSet, StateMap};
criterion_group!(
benches,
@@ -58,7 +55,7 @@ fn lexico_topo_sort(c: &mut Criterion) {
};
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))))
})
.await;
@@ -86,7 +83,7 @@ fn resolution_shallow_auth_chain(c: &mut Criterion) {
.collect::<Vec<_>>();
let func = async || {
if let Err(e) = tuwunel_core::matrix::state_res::resolve(
if let Err(e) = tuwunel_service::rooms::state_res::resolve(
&rules,
state_sets.clone().into_iter().stream(),
auth_chains.clone().into_iter().stream(),
@@ -169,7 +166,7 @@ fn resolve_deeper_event_set(c: &mut Criterion) {
.collect::<Vec<_>>();
let func = async || {
if let Err(e) = tuwunel_core::matrix::state_res::resolve(
if let Err(e) = tuwunel_service::rooms::state_res::resolve(
&rules,
state_sets.clone().into_iter().stream(),
auth_chains.clone().into_iter().stream(),

View File

@@ -29,8 +29,8 @@ use serde_json::value::RawValue as RawJsonValue;
use tuwunel_core::{
Err, Result, at, debug, debug_error, debug_info, debug_warn, err, error, implement, info,
matrix::{event::gen_event_id_canonical_json, room_version},
pdu::{PduBuilder, format::from_incoming_federation},
state_res, trace,
pdu::{PduBuilder, check_pdu_format, format::from_incoming_federation},
trace,
utils::{self, BoolExt, IterStream, ReadyExt, future::TryExtExt, math::Expected, shuffle},
warn,
};
@@ -41,6 +41,7 @@ use crate::{
rooms::{
state::RoomMutexGuard,
state_compressor::{CompressedState, HashSetCompressStateEvent},
state_res,
},
};
@@ -756,7 +757,7 @@ async fn create_join_event(
.server_keys
.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))
}

View File

@@ -16,9 +16,8 @@ use ruma::{
};
use tuwunel_core::{
Err, Result, debug_info, debug_warn, err, implement,
matrix::{PduCount, room_version},
matrix::{PduCount, pdu::check_pdu_format, room_version},
pdu::PduBuilder,
state_res,
utils::{
self, FutureBoolExt,
future::{ReadyBoolExt, TryExtExt},
@@ -354,7 +353,7 @@ async fn remote_leave(
.server_keys
.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
.federation

View File

@@ -8,10 +8,10 @@ use ruma::{
use tuwunel_core::{
Result, debug_warn, err, implement,
matrix::{Event, PduEvent},
state_res::{self},
};
use super::check_room_id;
use crate::rooms::state_res;
#[implement(super::Service)]
#[tracing::instrument(

View File

@@ -5,13 +5,14 @@ use ruma::{
use tuwunel_core::{
Err, Result, debug, debug_info, err, implement,
matrix::{Event, PduEvent, event::TypeExt, room_version},
pdu::format::from_incoming_federation,
ref_at, state_res, trace,
pdu::{check_pdu_format, format::from_incoming_federation},
ref_at, trace,
utils::{future::TryExtExt, stream::IterStream},
warn,
};
use super::check_room_id;
use crate::rooms::state_res;
#[implement(super::Service)]
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)?;
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
// convert to our PduEvent type.

View File

@@ -5,12 +5,14 @@ use ruma::{OwnedEventId, RoomId, RoomVersionId};
use tuwunel_core::{
Result, err, implement,
matrix::room_version,
state_res::{self, AuthSet, StateMap},
trace,
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)]
#[tracing::instrument(

View File

@@ -4,7 +4,7 @@ use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, future::try_join
use ruma::{OwnedEventId, RoomId, RoomVersionId};
use tuwunel_core::{
Result, apply, debug, debug_warn, err, implement,
matrix::{Event, StateMap, state_res::AuthSet},
matrix::Event,
ref_at, trace,
utils::{
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
#[implement(super::Service)]

View File

@@ -7,7 +7,7 @@ use ruma::{
};
use tuwunel_core::{
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,
utils::stream::{BroadbandExt, ReadyExt},
warn,
@@ -15,6 +15,7 @@ use tuwunel_core::{
use crate::rooms::{
state_compressor::{CompressedState, HashSetCompressStateEvent},
state_res,
timeline::RawPduId,
};
@@ -60,7 +61,7 @@ pub(super) async fn upgrade_outlier_to_timeline_pdu(
let room_rules = room_version::rules(room_version)?;
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
// backwards extremities doing all the checks in this list starting at 1.

View File

@@ -15,6 +15,7 @@ pub mod state;
pub mod state_accessor;
pub mod state_cache;
pub mod state_compressor;
pub mod state_res;
pub mod threads;
pub mod timeline;
pub mod typing;

View File

@@ -14,7 +14,6 @@ use tuwunel_core::{
implement,
matrix::{PduCount, RoomVersionRules, StateKey, TypeStateKey, room_version},
result::{AndThenRef, FlatOk},
state_res::{StateMap, auth_types_for_event},
trace,
utils::{
IterStream, MutexMap, MutexMapGuard, ReadyExt, calculate_hash,
@@ -29,6 +28,7 @@ use crate::{
rooms::{
short::{ShortEventId, ShortStateHash, ShortStateKey},
state_compressor::{CompressedState, parse_compressed_state_event},
state_res::{StateMap, auth_types_for_event},
},
services::OnceServices,
};

View File

@@ -29,10 +29,12 @@ use ruma::{
};
use tuwunel_core::{
Result, err, is_true,
matrix::{Pdu, room_version, state_res::events::RoomCreateEvent},
matrix::{Pdu, room_version},
utils::BoolExt,
};
use crate::rooms::state_res::events::RoomCreateEvent;
pub struct Service {
services: Arc<crate::services::OnceServices>,
}

View File

@@ -16,6 +16,12 @@ use ruma::{
},
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};
use self::room_member::check_room_member;
@@ -28,12 +34,6 @@ use super::{
power_levels::{self, RoomPowerLevelsEventOptionExt, RoomPowerLevelsIntField},
},
};
use crate::{
Err, Error, Result, err,
matrix::{Event, StateKey},
trace,
utils::stream::{IterStream, TryReadyExt},
};
#[tracing::instrument(
level = "debug",

View File

@@ -4,9 +4,9 @@ use ruma::{
room_version_rules::AuthorizationRules,
};
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 crate::{Err, Result, arrayvec::ArrayVec, matrix::pdu::MAX_AUTH_EVENTS};
pub type AuthTypes = ArrayVec<TypeStateKey, MAX_AUTH_EVENTS>;

View File

@@ -8,8 +8,7 @@ use ruma::{
serde::{Base64, base64::Standard},
signatures::verify_canonical_json_bytes,
};
use crate::{
use tuwunel_core::{
Err, Result, err, is_equal_to,
matrix::{Event, StateKey},
};

View File

@@ -14,6 +14,8 @@ use serde_json::{json, value::to_raw_value as to_raw_json_value};
mod room_power_levels;
use tuwunel_core::matrix::{EventHash, PduEvent, StateKey};
use self::room_power_levels::default_room_power_levels;
use super::{
check_room_create, check_room_redaction, check_state_dependent_auth_rules,
@@ -26,7 +28,6 @@ use super::{
to_pdu_event,
},
};
use crate::matrix::{EventHash, PduEvent, StateKey};
#[test]
fn valid_room_create() {
@@ -674,7 +675,7 @@ async fn auth_event_in_different_room() {
depth: uint!(0),
hashes: EventHash::default(),
signatures: None,
rejected: false,
//rejected: false,
};
init_events
.insert(power_level.event_id.clone(), power_level)
@@ -782,6 +783,7 @@ async fn unexpected_auth_event_type() {
}
#[tokio::test]
#[ignore = "PduEvent::rejected not conditionally compiled here"]
async fn rejected_auth_event() {
let _guard = init_subscriber();
@@ -812,7 +814,7 @@ async fn rejected_auth_event() {
depth: uint!(0),
hashes: EventHash::default(),
signatures: None,
rejected: true,
//rejected: true,
};
init_events
.insert(power_level.event_id.clone(), power_level)
@@ -903,7 +905,7 @@ async fn event_without_room_id() {
depth: uint!(0),
hashes: EventHash::default(),
signatures: None,
rejected: false,
//rejected: false,
};
let init_events = INITIAL_HYDRA_EVENTS();
@@ -1020,6 +1022,7 @@ async fn missing_room_create_in_fetch_event() {
}
#[tokio::test]
#[ignore = "PduEvent::rejected not conditionally compiled here"]
async fn rejected_room_create_in_fetch_event() {
let _guard = init_subscriber();
@@ -1035,8 +1038,8 @@ async fn rejected_room_create_in_fetch_event() {
let mut init_events = INITIAL_HYDRA_EVENTS();
let create_event_id = owned_event_id!("$CREATE");
let mut create_event = init_events.remove(&create_event_id).unwrap();
create_event.rejected = true;
let create_event = init_events.remove(&create_event_id).unwrap();
//create_event.rejected = true;
init_events.insert(create_event_id, create_event);
// Reject event if `m.room.create` was rejected.

View File

@@ -9,16 +9,13 @@ use serde_json::{
Value as JsonValue, json,
value::{Map as JsonMap, to_raw_value as to_raw_json_value},
};
use tuwunel_core::{extract_variant, info, matrix::PduEvent};
use super::{
super::{
check_room_power_levels,
events::RoomPowerLevelsEvent,
test_utils::{alice, bob, init_subscriber, to_pdu_event, zara},
},
PduEvent,
use super::super::{
check_room_power_levels,
events::RoomPowerLevelsEvent,
test_utils::{alice, bob, init_subscriber, to_pdu_event, zara},
};
use crate::{extract_variant, info};
/// The default `m.room.power_levels` event when creating a public room.
pub(super) fn default_room_power_levels() -> RoomPowerLevelsEvent<PduEvent> {

View File

@@ -27,7 +27,7 @@ pub use self::{
/// > that might remove someones ability to do something in the room.
pub(super) fn is_power_event<Pdu>(event: &Pdu) -> bool
where
Pdu: crate::matrix::Event,
Pdu: tuwunel_core::matrix::Event,
{
use ruma::events::{TimelineEventType, room::member::MembershipState};

View File

@@ -7,8 +7,7 @@ use ruma::{
serde::from_raw_json_value,
};
use serde::{Deserialize, de::IgnoredAny};
use crate::{Error, Result, err, matrix::Event};
use tuwunel_core::{Error, Result, err, matrix::Event};
/// A helper type for an [`Event`] of type `m.room.create`.
///

View File

@@ -4,8 +4,7 @@ use std::ops::Deref;
use ruma::serde::{PartialEqAsRefStr, StringEnum, from_raw_json_value};
use serde::Deserialize;
use crate::{Error, Result, err, matrix::Event};
use tuwunel_core::{Error, Result, err, matrix::Event};
/// A helper type for an [`Event`] of type `m.room.join_rules`.
///

View File

@@ -8,8 +8,7 @@ use ruma::{
};
use serde::Deserialize;
use serde_json::value::RawValue as RawJsonValue;
use crate::{Err, Error, Result, debug_error, err, matrix::Event};
use tuwunel_core::{Err, Error, Result, debug_error, err, matrix::Event};
/// A helper type for an [`Event`] of type `m.room.member`.
///

View File

@@ -15,8 +15,7 @@ use ruma::{
};
use serde::de::DeserializeOwned;
use serde_json::{Error, from_value as from_json_value};
use crate::{Result, err, is_equal_to, matrix::Event, ref_at};
use tuwunel_core::{Result, err, is_equal_to, matrix::Event, ref_at};
/// The default value of the creator's power level.
const DEFAULT_CREATOR_POWER_LEVEL: i32 = 100;

View File

@@ -4,8 +4,7 @@ use std::{collections::BTreeSet, ops::Deref};
use ruma::{serde::from_raw_json_value, third_party_invite::IdentityServerBase64PublicKey};
use serde::Deserialize;
use crate::{Error, Result, err, matrix::Event};
use tuwunel_core::{Error, Result, err, matrix::Event};
/// A helper type for an [`Event`] of type `m.room.third_party_invite`.
///

View File

@@ -2,15 +2,15 @@ use ruma::{
UserId,
events::{StateEventType, room::member::MembershipState},
};
use tuwunel_core::{
Result, err,
matrix::{Event, StateKey},
};
use super::events::{
JoinRule, RoomCreateEvent, RoomJoinRulesEvent, RoomMemberEvent, RoomPowerLevelsEvent,
RoomThirdPartyInviteEvent, member::RoomMemberEventResultExt,
};
use crate::{
Result, err,
matrix::{Event, StateKey},
};
pub(super) trait FetchStateExt<Pdu: Event> {
async fn room_create_event(&self) -> Result<RoomCreateEvent<Pdu>>;

View File

@@ -59,7 +59,6 @@
//! [ruma-events]: https://crates.io/crates/ruma-events
mod event_auth;
mod event_format;
pub mod events;
mod fetch_state;
mod resolve;
@@ -67,11 +66,11 @@ mod resolve;
mod test_utils;
pub mod topological_sort;
use tuwunel_core::matrix::TypeStateKey;
use self::{event_auth::check_state_dependent_auth_rules, fetch_state::FetchStateExt};
pub use self::{
event_auth::{AuthTypes, auth_check, auth_types_for_event},
event_format::check_pdu_format,
resolve::{AuthSet, ConflictMap, StateMap, resolve},
topological_sort::topological_sort,
};
use crate::matrix::TypeStateKey;

View File

@@ -14,18 +14,10 @@ use std::{
};
use futures::{FutureExt, Stream, StreamExt, TryFutureExt};
use itertools::Itertools;
use ruma::{OwnedEventId, events::StateEventType, room_version_rules::RoomVersionRules};
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::{
use tuwunel_core::{
Result, debug,
itertools::Itertools,
matrix::{Event, TypeStateKey},
smallvec::SmallVec,
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
/// `EventId`.
pub type StateMap<Id> = BTreeMap<TypeStateKey, Id>;

View File

@@ -2,9 +2,9 @@ use std::borrow::Borrow;
use futures::{FutureExt, Stream};
use ruma::EventId;
use tuwunel_core::utils::stream::{IterStream, ReadyExt};
use super::AuthSet;
use crate::utils::stream::{IterStream, ReadyExt};
/// Get the auth difference for the given auth chains.
///

View File

@@ -7,8 +7,7 @@ use std::{
use futures::{Future, FutureExt, Stream, StreamExt};
use ruma::OwnedEventId;
use crate::{
use tuwunel_core::{
Result, debug,
matrix::{Event, pdu::AuthEvents},
smallvec::SmallVec,

View File

@@ -4,12 +4,7 @@ use ruma::{
events::{StateEventType, TimelineEventType},
room_version_rules::RoomVersionRules,
};
use super::{
super::{auth_types_for_event, check_state_dependent_auth_rules},
StateMap,
};
use crate::{
use tuwunel_core::{
Error, Result, debug_warn, err, error,
matrix::{Event, EventTypeExt, StateKey},
smallvec::SmallVec,
@@ -17,6 +12,11 @@ use crate::{
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.
///
/// Definition in the specification:

View File

@@ -2,8 +2,7 @@ use futures::{
FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt, pin_mut, stream::try_unfold,
};
use ruma::{EventId, OwnedEventId, events::TimelineEventType};
use crate::{
use tuwunel_core::{
Error, Result, at, is_equal_to,
matrix::Event,
trace,

View File

@@ -9,6 +9,11 @@ use ruma::{
events::{TimelineEventType, room::power_levels::UserPowerLevel},
room_version_rules::RoomVersionRules,
};
use tuwunel_core::{
Result, err,
matrix::Event,
utils::stream::{BroadbandExt, IterStream, TryBroadbandExt},
};
use super::super::{
events::{
@@ -18,11 +23,6 @@ use super::super::{
topological_sort,
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
/// their auth chain that are in the full conflicted set, and sort it using

View File

@@ -1,9 +1,9 @@
use std::{collections::HashMap, hash::Hash, iter::IntoIterator};
use futures::{Stream, StreamExt};
use tuwunel_core::validated;
use super::{ConflictMap, StateMap};
use crate::validated;
/// Split the unconflicted state map and the conflicted state set.
///

View File

@@ -14,6 +14,11 @@ use ruma::{
uint,
};
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::{
StateMap,
@@ -23,11 +28,6 @@ use super::{
to_pdu_event, zara,
},
};
use crate::{
debug,
matrix::{Event, EventTypeExt, PduEvent},
utils::stream::IterStream,
};
async fn test_event_sort() {
_ = tracing::subscriber::set_default(

View File

@@ -26,17 +26,15 @@ use serde_json::{
json,
value::{RawValue as RawJsonValue, to_raw_value as to_raw_json_value},
};
use super::{AuthSet, StateMap, auth_types_for_event, events::RoomCreateEvent};
use crate::{
use tuwunel_core::{
Error, Result, err, info,
matrix::{
Event, EventHash, EventTypeExt, PduEvent, StateKey,
state_res::topological_sort::ReferencedIds,
},
matrix::{Event, EventHash, EventTypeExt, PduEvent, StateKey},
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);
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),
hashes: EventHash::default(),
signatures: None,
rejected: false,
//rejected: false,
}
}
@@ -502,7 +500,7 @@ where
depth: uint!(0),
hashes: EventHash::default(),
signatures: None,
rejected: false,
//rejected: false,
}
}
@@ -557,7 +555,7 @@ where
depth: uint!(0),
hashes: EventHash::default(),
signatures: None,
rejected: false,
//rejected: false,
}
}
@@ -605,7 +603,7 @@ where
depth: uint!(0),
hashes: EventHash::default(),
signatures: None,
rejected: false,
//rejected: false,
}
}
@@ -642,7 +640,7 @@ pub(super) fn room_create_hydra_pdu_event(
depth: uint!(0),
hashes: EventHash::default(),
signatures: None,
rejected: false,
//rejected: false,
}
}

View File

@@ -31,8 +31,7 @@ use futures::TryStreamExt;
use ruma::{
MilliSecondsSinceUnixEpoch, OwnedEventId, events::room::power_levels::UserPowerLevel,
};
use crate::{
use tuwunel_core::{
Error, Result, is_not_equal_to, smallvec::SmallVec, utils::stream::IterStream, validated,
};

View File

@@ -13,9 +13,8 @@ use tuwunel_core::{
Error, Result, err, implement,
matrix::{
event::{Event, StateKey, TypeExt},
pdu::{EventHash, PduBuilder, PduEvent, PrevEvents},
pdu::{EventHash, PduBuilder, PduEvent, PrevEvents, check_pdu_format},
room_version,
state_res::{self},
},
utils::{
IterStream, ReadyExt, TryReadyExt, millis_since_unix_epoch, stream::TryIgnore,
@@ -24,6 +23,7 @@ use tuwunel_core::{
};
use super::RoomMutexGuard;
use crate::rooms::state_res;
#[implement(super::Service)]
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()));
}
state_res::check_pdu_format(&pdu_json, &version_rules.event_format)?;
check_pdu_format(&pdu_json, &version_rules.event_format)?;
// Generate short event id
let _shorteventid = self

View File

@@ -23,12 +23,10 @@ use similar::{Algorithm, udiff::unified_diff};
use tracing_subscriber::EnvFilter;
use tuwunel_core::{
Result, err,
matrix::{
Event, Pdu, StateKey, StateMap,
state_res::{AuthSet, resolve},
},
matrix::{Event, Pdu, StateKey},
utils::stream::IterStream,
};
use tuwunel_service::rooms::state_res::{AuthSet, StateMap, resolve};
/// Create a new snapshot test.
///