Update ruma to latest, renamed server keys and removed PduStub
This commit is contained in:
parent
b869aab5d0
commit
164b1633d8
19 changed files with 123 additions and 87 deletions
69
Cargo.lock
generated
69
Cargo.lock
generated
|
@ -1210,6 +1210,12 @@ dependencies = [
|
|||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7151b083b0664ed58ed669fcdd92f01c3d2fdbf10af4931a301474950b52bfa9"
|
||||
|
||||
[[package]]
|
||||
name = "pear"
|
||||
version = "0.2.0-dev"
|
||||
|
@ -1611,7 +1617,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"assign",
|
||||
"js_int",
|
||||
|
@ -1629,24 +1635,22 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-api"
|
||||
version = "0.17.0-alpha.1"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"http",
|
||||
"percent-encoding",
|
||||
"ruma-api-macros",
|
||||
"ruma-common",
|
||||
"ruma-identifiers",
|
||||
"ruma-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-api-macros"
|
||||
version = "0.17.0-alpha.1"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
|
@ -1657,12 +1661,13 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-appservice-api"
|
||||
version = "0.2.0-alpha.1"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"ruma-api",
|
||||
"ruma-common",
|
||||
"ruma-events",
|
||||
"ruma-identifiers",
|
||||
"ruma-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
@ -1670,7 +1675,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-client-api"
|
||||
version = "0.10.0-alpha.1"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"assign",
|
||||
"http",
|
||||
|
@ -1684,38 +1689,25 @@ dependencies = [
|
|||
"ruma-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-common"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-common-macros",
|
||||
"maplit",
|
||||
"ruma-identifiers",
|
||||
"ruma-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-common-macros"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-events"
|
||||
version = "0.22.0-alpha.1"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-common",
|
||||
|
@ -1724,13 +1716,12 @@ dependencies = [
|
|||
"ruma-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-events-macros"
|
||||
version = "0.22.0-alpha.1"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
|
@ -1741,7 +1732,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-federation-api"
|
||||
version = "0.0.3"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-api",
|
||||
|
@ -1756,8 +1747,9 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-identifiers"
|
||||
version = "0.17.4"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"paste",
|
||||
"rand",
|
||||
"ruma-identifiers-macros",
|
||||
"ruma-identifiers-validation",
|
||||
|
@ -1769,7 +1761,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-identifiers-macros"
|
||||
version = "0.17.4"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -1780,28 +1772,39 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-identifiers-validation"
|
||||
version = "0.1.1"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"strum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-serde"
|
||||
version = "0.2.3"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"itoa",
|
||||
"js_int",
|
||||
"ruma-serde-macros",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-serde-macros"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-signatures"
|
||||
version = "0.6.0-dev.1"
|
||||
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237"
|
||||
dependencies = [
|
||||
"base64 0.12.3",
|
||||
"ring",
|
||||
|
@ -2059,7 +2062,7 @@ checksum = "3015a7d0a5fd5105c91c3710d42f9ccf0abfb287d62206484dcc67f9569a6483"
|
|||
[[package]]
|
||||
name = "state-res"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/ruma/state-res?branch=timo-spec-comp#d2a85669cc6056679ce6ca0fde4658a879ad2b08"
|
||||
source = "git+https://github.com/ruma/state-res?branch=timo-spec-comp#99214e6fa6b9843b0d9e1f6ef0698d7fdb234fb2"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"js_int",
|
||||
|
|
|
@ -18,14 +18,14 @@ edition = "2018"
|
|||
rocket = { git = "https://github.com/timokoesters/Rocket.git", branch = "empty_parameters", default-features = false, features = ["tls"] }
|
||||
|
||||
# Used for matrix spec type definitions and helpers
|
||||
ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks", "unstable-exhaustive-types"], rev = "c15382ca41262058302959eac4029ab4a1ea5889" }
|
||||
ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks", "unstable-exhaustive-types"], rev = "e8882fe8142d7b55ed4c8ccc6150946945f9e237" }
|
||||
# ruma = { git = "https://github.com/DevinR528/ruma", features = ["rand", "client-api", "federation-api", "unstable-exhaustive-types", "unstable-pre-spec", "unstable-synapse-quirks"], branch = "unstable-join" }
|
||||
# ruma = { path = "../ruma/ruma", features = ["unstable-exhaustive-types", "rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"] }
|
||||
|
||||
# Used when doing state resolution
|
||||
# state-res = { git = "https://github.com/timokoesters/state-res", branch = "spec-comp", features = ["unstable-pre-spec"] }
|
||||
state-res = { git = "https://github.com/ruma/state-res", branch = "timo-spec-comp", features = ["unstable-pre-spec", "gen-eventid"] }
|
||||
# state-res = { path = "../../state-res", features = ["unstable-pre-spec"] }
|
||||
# state-res = { path = "../../state-res", features = ["unstable-pre-spec", "gen-eventid"] }
|
||||
|
||||
# Used for long polling
|
||||
tokio = "0.2.22"
|
||||
|
|
|
@ -492,6 +492,7 @@ pub async fn register_route(
|
|||
body: "Thanks for trying out Conduit! This software is still in development, so expect many bugs and missing features. If you have federation enabled, you can join the Conduit chat room by typing <code>/join #conduit:matrix.org</code>. <strong>Important: Please don't join any other Matrix rooms over federation without permission from the room's admins.</strong> Some actions might trigger bugs in other server implementations, breaking the chat for everyone else.".to_owned(),
|
||||
}),
|
||||
relates_to: None,
|
||||
new_content: None,
|
||||
},
|
||||
))
|
||||
.expect("event is valid, we just created it"),
|
||||
|
|
|
@ -6,7 +6,7 @@ use ruma::{
|
|||
r0::config::{get_global_account_data, set_global_account_data},
|
||||
},
|
||||
events::{custom::CustomEventContent, BasicEvent},
|
||||
Raw,
|
||||
serde::Raw,
|
||||
};
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
|
|
|
@ -20,7 +20,8 @@ use ruma::{
|
|||
room::{avatar, canonical_alias, guest_access, history_visibility, name, topic},
|
||||
EventType,
|
||||
},
|
||||
Raw, ServerName,
|
||||
serde::Raw,
|
||||
ServerName,
|
||||
};
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
|
@ -83,7 +84,13 @@ pub async fn set_room_visibility_route(
|
|||
) -> ConduitResult<set_room_visibility::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
match body.visibility {
|
||||
match &body.visibility {
|
||||
room::Visibility::_Custom(_s) => {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
"Room visibility type is not supported.",
|
||||
));
|
||||
}
|
||||
room::Visibility::Public => {
|
||||
db.rooms.set_public(&body.room_id, true)?;
|
||||
info!("{} made {} public", sender_user, body.room_id);
|
||||
|
@ -294,7 +301,9 @@ pub async fn get_public_rooms_filtered_helper(
|
|||
.url,
|
||||
)
|
||||
})
|
||||
.transpose()?,
|
||||
.transpose()?
|
||||
// url is now an Option<String> so we must flatten
|
||||
.flatten(),
|
||||
};
|
||||
Ok(chunk)
|
||||
})
|
||||
|
|
|
@ -18,8 +18,8 @@ use ruma::{
|
|||
federation,
|
||||
},
|
||||
events::{pdu::Pdu, room::member, EventType},
|
||||
serde::{to_canonical_value, CanonicalJsonObject},
|
||||
EventId, Raw, RoomId, RoomVersionId, ServerName, UserId,
|
||||
serde::{to_canonical_value, CanonicalJsonObject, Raw},
|
||||
EventId, RoomId, RoomVersionId, ServerName, UserId,
|
||||
};
|
||||
use state_res::StateEvent;
|
||||
use std::{
|
||||
|
@ -541,7 +541,7 @@ async fn join_room_by_id_helper(
|
|||
federation::membership::create_join_event::v2::Request {
|
||||
room_id,
|
||||
event_id: &event_id,
|
||||
pdu_stub: PduEvent::convert_to_outgoing_federation_event(join_event.clone()),
|
||||
pdu: PduEvent::convert_to_outgoing_federation_event(join_event.clone()),
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
|
|
@ -32,7 +32,7 @@ pub async fn set_presence_route(
|
|||
.try_into()
|
||||
.expect("time is valid"),
|
||||
),
|
||||
presence: body.presence,
|
||||
presence: body.presence.clone(),
|
||||
status_msg: body.status_msg.clone(),
|
||||
},
|
||||
sender: sender_user.clone(),
|
||||
|
|
|
@ -8,7 +8,7 @@ use ruma::{
|
|||
},
|
||||
},
|
||||
events::EventType,
|
||||
Raw,
|
||||
serde::Raw,
|
||||
};
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
|
|
|
@ -10,7 +10,8 @@ use ruma::{
|
|||
room::{guest_access, history_visibility, join_rules, member, name, topic},
|
||||
EventType,
|
||||
},
|
||||
Raw, RoomAliasId, RoomId, RoomVersionId,
|
||||
serde::Raw,
|
||||
RoomAliasId, RoomId, RoomVersionId,
|
||||
};
|
||||
use std::{cmp::max, collections::BTreeMap, convert::TryFrom};
|
||||
|
||||
|
@ -141,10 +142,14 @@ pub async fn create_room_route(
|
|||
// 4. Events set by preset
|
||||
|
||||
// Figure out preset. We need it for preset specific events
|
||||
let preset = body.preset.unwrap_or_else(|| match body.visibility {
|
||||
room::Visibility::Private => create_room::RoomPreset::PrivateChat,
|
||||
room::Visibility::Public => create_room::RoomPreset::PublicChat,
|
||||
});
|
||||
let preset = body
|
||||
.preset
|
||||
.clone()
|
||||
.unwrap_or_else(|| match &body.visibility {
|
||||
room::Visibility::Private => create_room::RoomPreset::PrivateChat,
|
||||
room::Visibility::Public => create_room::RoomPreset::PublicChat,
|
||||
room::Visibility::_Custom(s) => create_room::RoomPreset::_Custom(s.into()),
|
||||
});
|
||||
|
||||
// 4.1 Join Rules
|
||||
db.rooms.build_and_append_pdu(
|
||||
|
|
|
@ -3,7 +3,8 @@ use crate::{ConduitResult, Database, Error, Ruma};
|
|||
use ruma::{
|
||||
api::client::r0::sync::sync_events,
|
||||
events::{room::member::MembershipState, AnySyncEphemeralRoomEvent, EventType},
|
||||
Raw, RoomId, UserId,
|
||||
serde::Raw,
|
||||
RoomId, UserId,
|
||||
};
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
|
|
|
@ -2,7 +2,8 @@ use crate::{utils, Error, Result};
|
|||
use ruma::{
|
||||
api::client::error::ErrorKind,
|
||||
events::{AnyEvent as EduEvent, EventType},
|
||||
Raw, RoomId, UserId,
|
||||
serde::Raw,
|
||||
RoomId, UserId,
|
||||
};
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use sled::IVec;
|
||||
|
|
|
@ -3,7 +3,10 @@ use std::convert::{TryFrom, TryInto};
|
|||
use crate::pdu::PduBuilder;
|
||||
use log::warn;
|
||||
use rocket::futures::{channel::mpsc, stream::StreamExt};
|
||||
use ruma::{events::room::message, events::EventType, UserId};
|
||||
use ruma::{
|
||||
events::{room::message, EventType},
|
||||
UserId,
|
||||
};
|
||||
use tokio::select;
|
||||
|
||||
pub enum AdminCommand {
|
||||
|
|
|
@ -15,8 +15,8 @@ use ruma::{
|
|||
},
|
||||
EventType,
|
||||
},
|
||||
serde::{to_canonical_value, CanonicalJsonObject},
|
||||
EventId, Raw, RoomAliasId, RoomId, RoomVersionId, ServerName, UserId,
|
||||
serde::{to_canonical_value, CanonicalJsonObject, Raw},
|
||||
EventId, RoomAliasId, RoomId, RoomVersionId, ServerName, UserId,
|
||||
};
|
||||
use sled::IVec;
|
||||
use state_res::{event_auth, Error as StateError, Requester, StateEvent, StateMap, StateStore};
|
||||
|
@ -102,7 +102,7 @@ impl StateStore for Rooms {
|
|||
.and_then(|pdu: StateEvent| {
|
||||
// conduit's PDU's always contain a room_id but some
|
||||
// of ruma's do not so this must be an Option
|
||||
if pdu.room_id() == Some(room_id) {
|
||||
if pdu.room_id() == room_id {
|
||||
Ok(Arc::new(pdu))
|
||||
} else {
|
||||
Err(StateError::NotFound(
|
||||
|
@ -278,7 +278,7 @@ impl Rooms {
|
|||
|
||||
for ((event_type, state_key), pdu_id) in state {
|
||||
let mut state_id = prefix.clone();
|
||||
state_id.extend_from_slice(&event_type.as_str().as_bytes());
|
||||
state_id.extend_from_slice(&event_type.as_ref().as_bytes());
|
||||
state_id.push(0xff);
|
||||
state_id.extend_from_slice(&state_key.as_bytes());
|
||||
self.stateid_pduid.insert(state_id, pdu_id)?;
|
||||
|
@ -592,6 +592,7 @@ impl Rooms {
|
|||
body: format!("Command: {}, Args: {:?}", command, args),
|
||||
formatted: None,
|
||||
relates_to: None,
|
||||
new_content: None,
|
||||
},
|
||||
));
|
||||
}
|
||||
|
@ -633,7 +634,7 @@ impl Rooms {
|
|||
|
||||
if let Some(state_key) = &new_pdu.state_key {
|
||||
let mut new_state = old_state;
|
||||
let mut pdu_key = new_pdu.kind.as_str().as_bytes().to_vec();
|
||||
let mut pdu_key = new_pdu.kind.as_ref().as_bytes().to_vec();
|
||||
pdu_key.push(0xff);
|
||||
pdu_key.extend_from_slice(state_key.as_bytes());
|
||||
new_state.insert(pdu_key.into(), new_pdu_id.into());
|
||||
|
|
|
@ -6,7 +6,8 @@ use ruma::{
|
|||
AnyEvent as EduEvent, SyncEphemeralRoomEvent,
|
||||
},
|
||||
presence::PresenceState,
|
||||
Raw, RoomId, UserId,
|
||||
serde::Raw,
|
||||
RoomId, UserId,
|
||||
};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
|
|
|
@ -10,7 +10,8 @@ use ruma::{
|
|||
},
|
||||
encryption::DeviceKeys,
|
||||
events::{AnyToDeviceEvent, EventType},
|
||||
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, Raw, UserId,
|
||||
serde::Raw,
|
||||
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId,
|
||||
};
|
||||
use std::{collections::BTreeMap, convert::TryFrom, mem, time::SystemTime};
|
||||
|
||||
|
|
|
@ -143,11 +143,7 @@ impl log::Log for ConduitLogger {
|
|||
}
|
||||
|
||||
self.db.admin.send(AdminCommand::SendTextMessage(
|
||||
message::TextMessageEventContent {
|
||||
body: output,
|
||||
formatted: None,
|
||||
relates_to: None,
|
||||
},
|
||||
message::TextMessageEventContent::plain(output),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
13
src/pdu.rs
13
src/pdu.rs
|
@ -5,8 +5,8 @@ use ruma::{
|
|||
pdu::EventHash, room::member::MemberEventContent, AnyEvent, AnyRoomEvent, AnyStateEvent,
|
||||
AnyStrippedStateEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType, StateEvent,
|
||||
},
|
||||
serde::{to_canonical_value, CanonicalJsonObject, CanonicalJsonValue},
|
||||
EventId, Raw, RoomId, RoomVersionId, ServerKeyId, ServerName, UserId,
|
||||
serde::{to_canonical_value, CanonicalJsonObject, CanonicalJsonValue, Raw},
|
||||
EventId, RoomId, RoomVersionId, ServerName, ServerSigningKeyId, UserId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
|
@ -36,7 +36,7 @@ pub struct PduEvent {
|
|||
#[serde(default, skip_serializing_if = "serde_json::Map::is_empty")]
|
||||
pub unsigned: serde_json::Map<String, serde_json::Value>,
|
||||
pub hashes: EventHash,
|
||||
pub signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerKeyId, String>>,
|
||||
pub signatures: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>,
|
||||
}
|
||||
|
||||
impl PduEvent {
|
||||
|
@ -205,9 +205,10 @@ impl PduEvent {
|
|||
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||
}
|
||||
|
||||
/// This does not return a full `Pdu` it is only to satisfy ruma's types.
|
||||
pub fn convert_to_outgoing_federation_event(
|
||||
mut pdu_json: CanonicalJsonObject,
|
||||
) -> Raw<ruma::events::pdu::PduStub> {
|
||||
) -> Raw<ruma::events::pdu::Pdu> {
|
||||
if let Some(CanonicalJsonValue::Object(unsigned)) = pdu_json.get_mut("unsigned") {
|
||||
unsigned.remove("transaction_id");
|
||||
}
|
||||
|
@ -232,7 +233,7 @@ impl From<&state_res::StateEvent> for PduEvent {
|
|||
fn from(pdu: &state_res::StateEvent) -> Self {
|
||||
Self {
|
||||
event_id: pdu.event_id(),
|
||||
room_id: pdu.room_id().unwrap().clone(),
|
||||
room_id: pdu.room_id().clone(),
|
||||
sender: pdu.sender().clone(),
|
||||
origin_server_ts: (pdu
|
||||
.origin_server_ts()
|
||||
|
@ -288,7 +289,7 @@ impl PduEvent {
|
|||
///
|
||||
/// Returns a tuple of the new `EventId` and the PDU with the eventId inserted as a `serde_json::Value`.
|
||||
pub(crate) fn process_incoming_pdu(
|
||||
pdu: &ruma::Raw<ruma::events::pdu::Pdu>,
|
||||
pdu: &Raw<ruma::events::pdu::Pdu>,
|
||||
) -> (EventId, CanonicalJsonObject) {
|
||||
let mut value =
|
||||
serde_json::from_str(pdu.json().get()).expect("A Raw<...> is always valid JSON");
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
use ruma::{
|
||||
push::{
|
||||
Action, ConditionalPushRule, ConditionalPushRuleInit, PatternedPushRule,
|
||||
PatternedPushRuleInit, PushCondition, RoomMemberCountIs, Ruleset, Tweak,
|
||||
Action, ConditionalPushRule, ConditionalPushRuleInit, ContentPushRule, OverridePushRule,
|
||||
PatternedPushRule, PatternedPushRuleInit, PushCondition, RoomMemberCountIs, Ruleset, Tweak,
|
||||
UnderridePushRule,
|
||||
},
|
||||
UserId,
|
||||
};
|
||||
|
||||
pub fn default_pushrules(user_id: &UserId) -> Ruleset {
|
||||
let mut rules = Ruleset::default();
|
||||
rules.content = vec![contains_user_name_rule(&user_id)];
|
||||
rules.override_ = vec![
|
||||
|
||||
rules.add(ContentPushRule(contains_user_name_rule(&user_id)));
|
||||
|
||||
for rule in vec![
|
||||
master_rule(),
|
||||
suppress_notices_rule(),
|
||||
invite_for_me_rule(),
|
||||
|
@ -17,14 +20,20 @@ pub fn default_pushrules(user_id: &UserId) -> Ruleset {
|
|||
contains_display_name_rule(),
|
||||
tombstone_rule(),
|
||||
roomnotif_rule(),
|
||||
];
|
||||
rules.underride = vec![
|
||||
] {
|
||||
rules.add(OverridePushRule(rule));
|
||||
}
|
||||
|
||||
for rule in vec![
|
||||
call_rule(),
|
||||
encrypted_room_one_to_one_rule(),
|
||||
room_one_to_one_rule(),
|
||||
message_rule(),
|
||||
encrypted_rule(),
|
||||
];
|
||||
] {
|
||||
rules.add(UnderridePushRule(rule));
|
||||
}
|
||||
|
||||
rules
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ use ruma::{
|
|||
federation::{
|
||||
directory::{get_public_rooms, get_public_rooms_filtered},
|
||||
discovery::{
|
||||
get_server_keys, get_server_version::v1 as get_server_version, ServerKey, VerifyKey,
|
||||
get_server_keys, get_server_version::v1 as get_server_version, ServerSigningKeys,
|
||||
VerifyKey,
|
||||
},
|
||||
event::get_missing_events,
|
||||
query::get_profile_information,
|
||||
|
@ -20,11 +21,11 @@ use ruma::{
|
|||
OutgoingRequest,
|
||||
},
|
||||
directory::{IncomingFilter, IncomingRoomNetwork},
|
||||
EventId, RoomId, ServerName, UserId,
|
||||
EventId, RoomId, ServerName, ServerSigningKeyId, UserId,
|
||||
};
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
convert::{TryFrom, TryInto},
|
||||
convert::TryFrom,
|
||||
fmt::Debug,
|
||||
sync::Arc,
|
||||
time::{Duration, SystemTime},
|
||||
|
@ -243,16 +244,17 @@ pub fn get_server_keys(db: State<'_, Database>) -> Json<String> {
|
|||
|
||||
let mut verify_keys = BTreeMap::new();
|
||||
verify_keys.insert(
|
||||
format!("ed25519:{}", db.globals.keypair().version())
|
||||
.try_into()
|
||||
.expect("DB stores valid ServerKeyId's"),
|
||||
ServerSigningKeyId::try_from(
|
||||
format!("ed25519:{}", db.globals.keypair().version()).as_str(),
|
||||
)
|
||||
.expect("found invalid server signing keys in DB"),
|
||||
VerifyKey {
|
||||
key: base64::encode_config(db.globals.keypair().public_key(), base64::STANDARD_NO_PAD),
|
||||
},
|
||||
);
|
||||
let mut response = serde_json::from_slice(
|
||||
http::Response::try_from(get_server_keys::v2::Response {
|
||||
server_key: ServerKey {
|
||||
server_key: ServerSigningKeys {
|
||||
server_name: db.globals.server_name().to_owned(),
|
||||
verify_keys,
|
||||
old_verify_keys: BTreeMap::new(),
|
||||
|
@ -430,7 +432,7 @@ pub async fn send_transaction_message_route<'a>(
|
|||
// would return a M_BAD_JSON error.
|
||||
let mut resolved_map = BTreeMap::new();
|
||||
for pdu in &body.pdus {
|
||||
// Ruma/PduEvent/StateEvent satifies - 1. Is a valid event, otherwise it is dropped.
|
||||
// Ruma/PduEvent/StateEvent satisfies - 1. Is a valid event, otherwise it is dropped.
|
||||
|
||||
// state-res checks signatures - 2. Passes signature checks, otherwise event is dropped.
|
||||
|
||||
|
@ -450,7 +452,7 @@ pub async fn send_transaction_message_route<'a>(
|
|||
continue;
|
||||
}
|
||||
|
||||
// If it is not a state event, we can skip state-res
|
||||
// If it is not a state event, we can skip state-res... maybe
|
||||
if value.get("state_key").is_none() {
|
||||
if !db.rooms.is_joined(&pdu.sender, room_id)? {
|
||||
warn!("Sender is not joined {}", pdu.kind);
|
||||
|
@ -679,7 +681,9 @@ pub fn get_profile_information_route<'a>(
|
|||
let mut displayname = None;
|
||||
let mut avatar_url = None;
|
||||
|
||||
match body.field {
|
||||
match &body.field {
|
||||
// TODO: what to do with custom
|
||||
Some(ProfileField::_Custom(_s)) => {}
|
||||
Some(ProfileField::DisplayName) => displayname = db.users.displayname(&body.user_id)?,
|
||||
Some(ProfileField::AvatarUrl) => avatar_url = db.users.avatar_url(&body.user_id)?,
|
||||
None => {
|
||||
|
|
Loading…
Add table
Reference in a new issue