Merge pull request 'Switch to the ruma meta-crate' (#106) from jplatte/conduit:master into master
Reviewed-by: Timo Kösters <timo@koesters.xyz>
This commit is contained in:
commit
8f6b446193
14 changed files with 197 additions and 202 deletions
75
Cargo.lock
generated
75
Cargo.lock
generated
|
@ -160,13 +160,7 @@ dependencies = [
|
|||
"rand",
|
||||
"reqwest",
|
||||
"rocket",
|
||||
"ruma-api",
|
||||
"ruma-client-api",
|
||||
"ruma-common",
|
||||
"ruma-events 0.21.3 (git+https://github.com/ruma/ruma-events?rev=c1ee72d)",
|
||||
"ruma-federation-api",
|
||||
"ruma-identifiers",
|
||||
"ruma-signatures",
|
||||
"ruma",
|
||||
"rust-argon2 0.8.2",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
@ -1266,11 +1260,24 @@ dependencies = [
|
|||
"unicode-xid 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=f6fb971329a4a5a7faeebf7ea47a86cd19e580f4#f6fb971329a4a5a7faeebf7ea47a86cd19e580f4"
|
||||
dependencies = [
|
||||
"ruma-api",
|
||||
"ruma-client-api",
|
||||
"ruma-common",
|
||||
"ruma-events",
|
||||
"ruma-federation-api",
|
||||
"ruma-identifiers",
|
||||
"ruma-signatures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-api"
|
||||
version = "0.16.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82ffdb7fb9cf6af2b1d0d8254d922560ecb70081d7e70931c9b996b6b4839db5"
|
||||
source = "git+https://github.com/ruma/ruma?rev=f6fb971329a4a5a7faeebf7ea47a86cd19e580f4#f6fb971329a4a5a7faeebf7ea47a86cd19e580f4"
|
||||
dependencies = [
|
||||
"http",
|
||||
"percent-encoding 2.1.0",
|
||||
|
@ -1285,8 +1292,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-api-macros"
|
||||
version = "0.16.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52b82b4567b9af9b40a86f7778821c016ea961f55e4fee255f8f24bb28ee7452"
|
||||
source = "git+https://github.com/ruma/ruma?rev=f6fb971329a4a5a7faeebf7ea47a86cd19e580f4#f6fb971329a4a5a7faeebf7ea47a86cd19e580f4"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.18",
|
||||
"quote 1.0.6",
|
||||
|
@ -1296,13 +1302,13 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-client-api"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/ruma/ruma-client-api.git?rev=632eb9d520028816c5fb7224bd0aca8d1e3793f1#632eb9d520028816c5fb7224bd0aca8d1e3793f1"
|
||||
source = "git+https://github.com/ruma/ruma?rev=f6fb971329a4a5a7faeebf7ea47a86cd19e580f4#f6fb971329a4a5a7faeebf7ea47a86cd19e580f4"
|
||||
dependencies = [
|
||||
"http",
|
||||
"js_int",
|
||||
"ruma-api",
|
||||
"ruma-common",
|
||||
"ruma-events 0.21.3 (git+https://github.com/ruma/ruma-events?rev=c1ee72d)",
|
||||
"ruma-events",
|
||||
"ruma-identifiers",
|
||||
"ruma-serde",
|
||||
"serde",
|
||||
|
@ -1313,8 +1319,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-common"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6cb49e83277e82c69cc258cedc7e68b3d72ba378f1cb6105cbfcc8831e422b4d"
|
||||
source = "git+https://github.com/ruma/ruma?rev=f6fb971329a4a5a7faeebf7ea47a86cd19e580f4#f6fb971329a4a5a7faeebf7ea47a86cd19e580f4"
|
||||
dependencies = [
|
||||
"matches",
|
||||
"ruma-serde",
|
||||
|
@ -1330,7 +1335,7 @@ source = "git+https://github.com/ruma/ruma-events?rev=c1ee72d#c1ee72db0f3107a97f
|
|||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-common",
|
||||
"ruma-events-macros 0.21.3 (git+https://github.com/ruma/ruma-events?rev=c1ee72d)",
|
||||
"ruma-events-macros",
|
||||
"ruma-identifiers",
|
||||
"ruma-serde",
|
||||
"serde",
|
||||
|
@ -1338,21 +1343,6 @@ dependencies = [
|
|||
"strum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-events"
|
||||
version = "0.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ddf82c2231e4c53443424df34e868e4b09c20de7a76780d47a133a3b3f8ad9c"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-common",
|
||||
"ruma-events-macros 0.21.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ruma-identifiers",
|
||||
"ruma-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-events-macros"
|
||||
version = "0.21.3"
|
||||
|
@ -1363,26 +1353,16 @@ dependencies = [
|
|||
"syn 1.0.30",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-events-macros"
|
||||
version = "0.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88e5c5b242fe4ee0cc56879057353621196d0988dd359579cad8f43471e483b7"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.18",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.30",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruma-federation-api"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/ruma/ruma-federation-api.git?rev=4cf4aa6ef74b25ad8c14d99d7774129f023df163#4cf4aa6ef74b25ad8c14d99d7774129f023df163"
|
||||
version = "0.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff655a4cb7d43b60b18e07a601889836c1c12854bb16f4c083826b664fdc55aa"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"matches",
|
||||
"ruma-api",
|
||||
"ruma-events 0.21.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ruma-events",
|
||||
"ruma-identifiers",
|
||||
"ruma-serde",
|
||||
"serde",
|
||||
|
@ -1402,8 +1382,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-serde"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c71dabb8e2709ca4f59201cb72d7fe8d590e7e3f55feb348e851c18354938af"
|
||||
source = "git+https://github.com/ruma/ruma?rev=f6fb971329a4a5a7faeebf7ea47a86cd19e580f4#f6fb971329a4a5a7faeebf7ea47a86cd19e580f4"
|
||||
dependencies = [
|
||||
"dtoa",
|
||||
"itoa",
|
||||
|
@ -1416,7 +1395,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-signatures"
|
||||
version = "0.6.0-dev.1"
|
||||
source = "git+https://github.com/ruma/ruma-signatures.git?rev=1ca545cba8dfd43e0fc8e3c18e1311fb73390a97#1ca545cba8dfd43e0fc8e3c18e1311fb73390a97"
|
||||
source = "git+https://github.com/ruma/ruma?rev=f6fb971329a4a5a7faeebf7ea47a86cd19e580f4#f6fb971329a4a5a7faeebf7ea47a86cd19e580f4"
|
||||
dependencies = [
|
||||
"base64 0.12.1",
|
||||
"ring",
|
||||
|
|
20
Cargo.toml
20
Cargo.toml
|
@ -12,14 +12,6 @@ edition = "2018"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
ruma-client-api = { git = "https://github.com/ruma/ruma-client-api.git", rev = "632eb9d520028816c5fb7224bd0aca8d1e3793f1" }
|
||||
ruma-identifiers = { version = "0.16.2", features = ["rand"] }
|
||||
ruma-api = "0.16.1"
|
||||
ruma-events = { git = "https://github.com/ruma/ruma-events.git", rev = "c1ee72d" }
|
||||
ruma-signatures = { git = "https://github.com/ruma/ruma-signatures.git", rev = "1ca545cba8dfd43e0fc8e3c18e1311fb73390a97" }
|
||||
ruma-federation-api = { git = "https://github.com/ruma/ruma-federation-api.git", rev = "4cf4aa6ef74b25ad8c14d99d7774129f023df163" }
|
||||
ruma-common = "0.1.3"
|
||||
|
||||
rocket = { git = "https://github.com/SergioBenitez/Rocket.git", branch = "async", features = ["tls"] }
|
||||
http = "0.2.1"
|
||||
log = "0.4.8"
|
||||
|
@ -35,3 +27,15 @@ reqwest = "0.10.6"
|
|||
base64 = "0.12.1"
|
||||
thiserror = "1.0.19"
|
||||
image = { version = "0.23.4", default-features = false, features = ["jpeg", "png", "gif"] }
|
||||
|
||||
[dependencies.ruma]
|
||||
git = "https://github.com/ruma/ruma"
|
||||
rev = "f6fb971329a4a5a7faeebf7ea47a86cd19e580f4"
|
||||
features = ["rand", "client-api", "federation-api"]
|
||||
|
||||
# These are required only until ruma-events and ruma-federation-api are merged into ruma/ruma
|
||||
[patch.crates-io]
|
||||
ruma-api = { git = "https://github.com/ruma/ruma", rev = "f6fb971329a4a5a7faeebf7ea47a86cd19e580f4" }
|
||||
ruma-common = { git = "https://github.com/ruma/ruma", rev = "f6fb971329a4a5a7faeebf7ea47a86cd19e580f4" }
|
||||
ruma-events = { git = "https://github.com/ruma/ruma-events", rev = "c1ee72d" }
|
||||
ruma-serde = { git = "https://github.com/ruma/ruma", rev = "f6fb971329a4a5a7faeebf7ea47a86cd19e580f4" }
|
||||
|
|
|
@ -7,55 +7,57 @@ use std::{
|
|||
use crate::{utils, Database, MatrixResult, Ruma};
|
||||
use log::{debug, warn};
|
||||
use rocket::{delete, get, options, post, put, State};
|
||||
use ruma_client_api::{
|
||||
error::{Error, ErrorKind},
|
||||
r0::{
|
||||
account::{get_username_availability, register},
|
||||
alias::{create_alias, delete_alias, get_alias},
|
||||
capabilities::get_capabilities,
|
||||
config::{get_global_account_data, set_global_account_data},
|
||||
context::get_context,
|
||||
device::{self, delete_device, delete_devices, get_device, get_devices, update_device},
|
||||
directory::{
|
||||
self, get_public_rooms, get_public_rooms_filtered, get_room_visibility,
|
||||
set_room_visibility,
|
||||
use ruma::{
|
||||
api::client::{
|
||||
error::{Error, ErrorKind},
|
||||
r0::{
|
||||
account::{get_username_availability, register},
|
||||
alias::{create_alias, delete_alias, get_alias},
|
||||
capabilities::get_capabilities,
|
||||
config::{get_global_account_data, set_global_account_data},
|
||||
context::get_context,
|
||||
device::{self, delete_device, delete_devices, get_device, get_devices, update_device},
|
||||
directory::{
|
||||
self, get_public_rooms, get_public_rooms_filtered, get_room_visibility,
|
||||
set_room_visibility,
|
||||
},
|
||||
filter::{self, create_filter, get_filter},
|
||||
keys::{self, claim_keys, get_keys, upload_keys},
|
||||
media::{create_content, get_content, get_content_thumbnail, get_media_config},
|
||||
membership::{
|
||||
ban_user, forget_room, get_member_events, invite_user, join_room_by_id,
|
||||
join_room_by_id_or_alias, kick_user, leave_room, unban_user,
|
||||
},
|
||||
message::{create_message_event, get_message_events},
|
||||
presence::set_presence,
|
||||
profile::{
|
||||
get_avatar_url, get_display_name, get_profile, set_avatar_url, set_display_name,
|
||||
},
|
||||
push::{get_pushrules_all, set_pushrule, set_pushrule_enabled},
|
||||
read_marker::set_read_marker,
|
||||
redact::redact_event,
|
||||
room::{self, create_room},
|
||||
session::{get_login_types, login, logout},
|
||||
state::{
|
||||
create_state_event_for_empty_key, create_state_event_for_key, get_state_events,
|
||||
get_state_events_for_empty_key, get_state_events_for_key,
|
||||
},
|
||||
sync::sync_events,
|
||||
thirdparty::get_protocols,
|
||||
to_device::{self, send_event_to_device},
|
||||
typing::create_typing_event,
|
||||
uiaa::{AuthFlow, UiaaInfo, UiaaResponse},
|
||||
user_directory::search_users,
|
||||
},
|
||||
filter::{self, create_filter, get_filter},
|
||||
keys::{self, claim_keys, get_keys, upload_keys},
|
||||
media::{create_content, get_content, get_content_thumbnail, get_media_config},
|
||||
membership::{
|
||||
ban_user, forget_room, get_member_events, invite_user, join_room_by_id,
|
||||
join_room_by_id_or_alias, kick_user, leave_room, unban_user,
|
||||
},
|
||||
message::{create_message_event, get_message_events},
|
||||
presence::set_presence,
|
||||
profile::{
|
||||
get_avatar_url, get_display_name, get_profile, set_avatar_url, set_display_name,
|
||||
},
|
||||
push::{get_pushrules_all, set_pushrule, set_pushrule_enabled},
|
||||
read_marker::set_read_marker,
|
||||
redact::redact_event,
|
||||
room::{self, create_room},
|
||||
session::{get_login_types, login, logout},
|
||||
state::{
|
||||
create_state_event_for_empty_key, create_state_event_for_key, get_state_events,
|
||||
get_state_events_for_empty_key, get_state_events_for_key,
|
||||
},
|
||||
sync::sync_events,
|
||||
thirdparty::get_protocols,
|
||||
to_device::{self, send_event_to_device},
|
||||
typing::create_typing_event,
|
||||
uiaa::{AuthFlow, UiaaInfo, UiaaResponse},
|
||||
user_directory::search_users,
|
||||
unversioned::get_supported_versions,
|
||||
},
|
||||
unversioned::get_supported_versions,
|
||||
events::{
|
||||
collections::only::Event as EduEvent,
|
||||
room::{canonical_alias, guest_access, history_visibility, join_rules, member, redaction},
|
||||
EventJson, EventType,
|
||||
},
|
||||
identifiers::{DeviceId, RoomAliasId, RoomId, RoomVersionId, UserId},
|
||||
};
|
||||
use ruma_events::{
|
||||
collections::only::Event as EduEvent,
|
||||
room::{canonical_alias, guest_access, history_visibility, join_rules, member, redaction},
|
||||
EventJson, EventType,
|
||||
};
|
||||
use ruma_identifiers::{DeviceId, RoomAliasId, RoomId, RoomVersionId, UserId};
|
||||
use serde_json::{json, value::RawValue};
|
||||
|
||||
const GUEST_NAME_LENGTH: usize = 10;
|
||||
|
@ -197,12 +199,12 @@ pub fn register_route(
|
|||
None,
|
||||
&user_id,
|
||||
&EventType::PushRules,
|
||||
serde_json::to_value(ruma_events::push_rules::PushRulesEvent {
|
||||
content: ruma_events::push_rules::PushRulesEventContent {
|
||||
global: ruma_events::push_rules::Ruleset {
|
||||
serde_json::to_value(ruma::events::push_rules::PushRulesEvent {
|
||||
content: ruma::events::push_rules::PushRulesEventContent {
|
||||
global: ruma::events::push_rules::Ruleset {
|
||||
content: vec![],
|
||||
override_: vec![ruma_events::push_rules::ConditionalPushRule {
|
||||
actions: vec![ruma_events::push_rules::Action::DontNotify],
|
||||
override_: vec![ruma::events::push_rules::ConditionalPushRule {
|
||||
actions: vec![ruma::events::push_rules::Action::DontNotify],
|
||||
default: true,
|
||||
enabled: false,
|
||||
rule_id: ".m.rule.master".to_owned(),
|
||||
|
@ -210,17 +212,17 @@ pub fn register_route(
|
|||
}],
|
||||
room: vec![],
|
||||
sender: vec![],
|
||||
underride: vec![ruma_events::push_rules::ConditionalPushRule {
|
||||
underride: vec![ruma::events::push_rules::ConditionalPushRule {
|
||||
actions: vec![
|
||||
ruma_events::push_rules::Action::Notify,
|
||||
ruma_events::push_rules::Action::SetTweak(
|
||||
ruma_common::push::Tweak::Sound("default".to_owned()),
|
||||
ruma::events::push_rules::Action::Notify,
|
||||
ruma::events::push_rules::Action::SetTweak(
|
||||
ruma::push::Tweak::Sound("default".to_owned()),
|
||||
),
|
||||
],
|
||||
default: true,
|
||||
enabled: true,
|
||||
rule_id: ".m.rule.message".to_owned(),
|
||||
conditions: vec![ruma_events::push_rules::PushCondition::EventMatch {
|
||||
conditions: vec![ruma::events::push_rules::PushCondition::EventMatch {
|
||||
key: "type".to_owned(),
|
||||
pattern: "m.room.message".to_owned(),
|
||||
}],
|
||||
|
@ -522,7 +524,7 @@ pub fn set_displayname_route(
|
|||
room_id.clone(),
|
||||
user_id.clone(),
|
||||
EventType::RoomMember,
|
||||
serde_json::to_value(ruma_events::room::member::MemberEventContent {
|
||||
serde_json::to_value(ruma::events::room::member::MemberEventContent {
|
||||
displayname: body.displayname.clone(),
|
||||
..serde_json::from_value::<EventJson<_>>(
|
||||
db.rooms
|
||||
|
@ -549,13 +551,13 @@ pub fn set_displayname_route(
|
|||
// Presence update
|
||||
db.global_edus
|
||||
.update_presence(
|
||||
ruma_events::presence::PresenceEvent {
|
||||
content: ruma_events::presence::PresenceEventContent {
|
||||
ruma::events::presence::PresenceEvent {
|
||||
content: ruma::events::presence::PresenceEventContent {
|
||||
avatar_url: db.users.avatar_url(&user_id).unwrap(),
|
||||
currently_active: None,
|
||||
displayname: db.users.displayname(&user_id).unwrap(),
|
||||
last_active_ago: Some(utils::millis_since_unix_epoch().try_into().unwrap()),
|
||||
presence: ruma_events::presence::PresenceState::Online,
|
||||
presence: ruma::events::presence::PresenceState::Online,
|
||||
status_msg: None,
|
||||
},
|
||||
sender: user_id.clone(),
|
||||
|
@ -613,7 +615,7 @@ pub fn set_avatar_url_route(
|
|||
room_id.clone(),
|
||||
user_id.clone(),
|
||||
EventType::RoomMember,
|
||||
serde_json::to_value(ruma_events::room::member::MemberEventContent {
|
||||
serde_json::to_value(ruma::events::room::member::MemberEventContent {
|
||||
avatar_url: body.avatar_url.clone(),
|
||||
..serde_json::from_value::<EventJson<_>>(
|
||||
db.rooms
|
||||
|
@ -640,13 +642,13 @@ pub fn set_avatar_url_route(
|
|||
// Presence update
|
||||
db.global_edus
|
||||
.update_presence(
|
||||
ruma_events::presence::PresenceEvent {
|
||||
content: ruma_events::presence::PresenceEventContent {
|
||||
ruma::events::presence::PresenceEvent {
|
||||
content: ruma::events::presence::PresenceEventContent {
|
||||
avatar_url: db.users.avatar_url(&user_id).unwrap(),
|
||||
currently_active: None,
|
||||
displayname: db.users.displayname(&user_id).unwrap(),
|
||||
last_active_ago: Some(utils::millis_since_unix_epoch().try_into().unwrap()),
|
||||
presence: ruma_events::presence::PresenceState::Online,
|
||||
presence: ruma::events::presence::PresenceState::Online,
|
||||
status_msg: None,
|
||||
},
|
||||
sender: user_id.clone(),
|
||||
|
@ -706,8 +708,8 @@ pub fn set_presence_route(
|
|||
|
||||
db.global_edus
|
||||
.update_presence(
|
||||
ruma_events::presence::PresenceEvent {
|
||||
content: ruma_events::presence::PresenceEventContent {
|
||||
ruma::events::presence::PresenceEvent {
|
||||
content: ruma::events::presence::PresenceEventContent {
|
||||
avatar_url: db.users.avatar_url(&user_id).unwrap(),
|
||||
currently_active: None,
|
||||
displayname: db.users.displayname(&user_id).unwrap(),
|
||||
|
@ -848,8 +850,8 @@ pub fn set_read_marker_route(
|
|||
Some(&body.room_id),
|
||||
&user_id,
|
||||
&EventType::FullyRead,
|
||||
serde_json::to_value(ruma_events::fully_read::FullyReadEvent {
|
||||
content: ruma_events::fully_read::FullyReadEventContent {
|
||||
serde_json::to_value(ruma::events::fully_read::FullyReadEvent {
|
||||
content: ruma::events::fully_read::FullyReadEventContent {
|
||||
event_id: body.fully_read.clone(),
|
||||
},
|
||||
room_id: Some(body.room_id.clone()),
|
||||
|
@ -877,14 +879,14 @@ pub fn set_read_marker_route(
|
|||
let mut user_receipts = BTreeMap::new();
|
||||
user_receipts.insert(
|
||||
user_id.clone(),
|
||||
ruma_events::receipt::Receipt {
|
||||
ruma::events::receipt::Receipt {
|
||||
ts: Some(SystemTime::now()),
|
||||
},
|
||||
);
|
||||
let mut receipt_content = BTreeMap::new();
|
||||
receipt_content.insert(
|
||||
event.clone(),
|
||||
ruma_events::receipt::Receipts {
|
||||
ruma::events::receipt::Receipts {
|
||||
read: Some(user_receipts),
|
||||
},
|
||||
);
|
||||
|
@ -894,7 +896,7 @@ pub fn set_read_marker_route(
|
|||
.roomlatest_update(
|
||||
&user_id,
|
||||
&body.room_id,
|
||||
EduEvent::Receipt(ruma_events::receipt::ReceiptEvent {
|
||||
EduEvent::Receipt(ruma::events::receipt::ReceiptEvent {
|
||||
content: receipt_content,
|
||||
room_id: None, // None because it can be inferred
|
||||
}),
|
||||
|
@ -977,7 +979,7 @@ pub fn create_room_route(
|
|||
room_id.clone(),
|
||||
user_id.clone(),
|
||||
EventType::RoomCreate,
|
||||
serde_json::to_value(ruma_events::room::create::CreateEventContent {
|
||||
serde_json::to_value(ruma::events::room::create::CreateEventContent {
|
||||
creator: user_id.clone(),
|
||||
federate: body.creation_content.as_ref().map_or(true, |c| c.federate),
|
||||
predecessor: body
|
||||
|
@ -1033,7 +1035,7 @@ pub fn create_room_route(
|
|||
serde_json::from_str(power_levels.json().get())
|
||||
.expect("TODO: handle. we hope the client sends a valid power levels json")
|
||||
} else {
|
||||
serde_json::to_value(ruma_events::room::power_levels::PowerLevelsEventContent {
|
||||
serde_json::to_value(ruma::events::room::power_levels::PowerLevelsEventContent {
|
||||
ban: 50.into(),
|
||||
events: BTreeMap::new(),
|
||||
events_default: 0.into(),
|
||||
|
@ -1043,7 +1045,7 @@ pub fn create_room_route(
|
|||
state_default: 50.into(),
|
||||
users,
|
||||
users_default: 0.into(),
|
||||
notifications: ruma_events::room::power_levels::NotificationPowerLevels {
|
||||
notifications: ruma::events::room::power_levels::NotificationPowerLevels {
|
||||
room: 50.into(),
|
||||
},
|
||||
})
|
||||
|
@ -1159,7 +1161,7 @@ pub fn create_room_route(
|
|||
user_id.clone(),
|
||||
EventType::RoomName,
|
||||
serde_json::to_value(
|
||||
ruma_events::room::name::NameEventContent::new(name.clone()).unwrap(),
|
||||
ruma::events::room::name::NameEventContent::new(name.clone()).unwrap(),
|
||||
)
|
||||
.unwrap(),
|
||||
None,
|
||||
|
@ -1176,7 +1178,7 @@ pub fn create_room_route(
|
|||
room_id.clone(),
|
||||
user_id.clone(),
|
||||
EventType::RoomTopic,
|
||||
serde_json::to_value(ruma_events::room::topic::TopicEventContent {
|
||||
serde_json::to_value(ruma::events::room::topic::TopicEventContent {
|
||||
topic: topic.clone(),
|
||||
})
|
||||
.unwrap(),
|
||||
|
@ -1433,7 +1435,7 @@ pub fn leave_room_route(
|
|||
let state = db.rooms.room_state(&body.room_id).unwrap();
|
||||
|
||||
let mut event =
|
||||
serde_json::from_value::<EventJson<ruma_events::room::member::MemberEventContent>>(
|
||||
serde_json::from_value::<EventJson<ruma::events::room::member::MemberEventContent>>(
|
||||
state
|
||||
.get(&(EventType::RoomMember, user_id.to_string()))
|
||||
.unwrap() // TODO: error handling
|
||||
|
@ -1444,7 +1446,7 @@ pub fn leave_room_route(
|
|||
.deserialize()
|
||||
.unwrap();
|
||||
|
||||
event.membership = ruma_events::room::member::MembershipState::Leave;
|
||||
event.membership = ruma::events::room::member::MembershipState::Leave;
|
||||
|
||||
db.rooms
|
||||
.append_pdu(
|
||||
|
@ -1472,7 +1474,7 @@ pub fn kick_user_route(
|
|||
let state = db.rooms.room_state(&body.room_id).unwrap();
|
||||
|
||||
let mut event =
|
||||
serde_json::from_value::<EventJson<ruma_events::room::member::MemberEventContent>>(
|
||||
serde_json::from_value::<EventJson<ruma::events::room::member::MemberEventContent>>(
|
||||
state
|
||||
.get(&(EventType::RoomMember, user_id.to_string()))
|
||||
.unwrap() // TODO: error handling
|
||||
|
@ -1483,7 +1485,7 @@ pub fn kick_user_route(
|
|||
.deserialize()
|
||||
.unwrap();
|
||||
|
||||
event.membership = ruma_events::room::member::MembershipState::Leave;
|
||||
event.membership = ruma::events::room::member::MembershipState::Leave;
|
||||
// TODO: reason
|
||||
|
||||
db.rooms
|
||||
|
@ -1512,7 +1514,7 @@ pub fn ban_user_route(
|
|||
let state = db.rooms.room_state(&body.room_id).unwrap();
|
||||
|
||||
let mut event =
|
||||
serde_json::from_value::<EventJson<ruma_events::room::member::MemberEventContent>>(
|
||||
serde_json::from_value::<EventJson<ruma::events::room::member::MemberEventContent>>(
|
||||
state
|
||||
.get(&(EventType::RoomMember, user_id.to_string()))
|
||||
.unwrap() // TODO: error handling
|
||||
|
@ -1523,7 +1525,7 @@ pub fn ban_user_route(
|
|||
.deserialize()
|
||||
.unwrap();
|
||||
|
||||
event.membership = ruma_events::room::member::MembershipState::Ban;
|
||||
event.membership = ruma::events::room::member::MembershipState::Ban;
|
||||
// TODO: reason
|
||||
|
||||
db.rooms
|
||||
|
@ -1552,7 +1554,7 @@ pub fn unban_user_route(
|
|||
let state = db.rooms.room_state(&body.room_id).unwrap();
|
||||
|
||||
let mut event =
|
||||
serde_json::from_value::<EventJson<ruma_events::room::member::MemberEventContent>>(
|
||||
serde_json::from_value::<EventJson<ruma::events::room::member::MemberEventContent>>(
|
||||
state
|
||||
.get(&(EventType::RoomMember, user_id.to_string()))
|
||||
.unwrap() // TODO: error handling
|
||||
|
@ -1563,7 +1565,7 @@ pub fn unban_user_route(
|
|||
.deserialize()
|
||||
.unwrap();
|
||||
|
||||
event.membership = ruma_events::room::member::MembershipState::Leave;
|
||||
event.membership = ruma::events::room::member::MembershipState::Leave;
|
||||
|
||||
db.rooms
|
||||
.append_pdu(
|
||||
|
@ -1727,7 +1729,7 @@ pub async fn get_public_rooms_filtered_route(
|
|||
aliases: Vec::new(),
|
||||
canonical_alias: state.get(&(EventType::RoomCanonicalAlias, "".to_owned())).and_then(|s| {
|
||||
serde_json::from_value::<
|
||||
EventJson<ruma_events::room::canonical_alias::CanonicalAliasEventContent>,
|
||||
EventJson<ruma::events::room::canonical_alias::CanonicalAliasEventContent>,
|
||||
>(s.content.clone())
|
||||
.unwrap()
|
||||
.deserialize()
|
||||
|
@ -1735,7 +1737,7 @@ pub async fn get_public_rooms_filtered_route(
|
|||
.alias
|
||||
}),
|
||||
name: state.get(&(EventType::RoomName, "".to_owned())).map(|s| {
|
||||
serde_json::from_value::<EventJson<ruma_events::room::name::NameEventContent>>(
|
||||
serde_json::from_value::<EventJson<ruma::events::room::name::NameEventContent>>(
|
||||
s.content.clone(),
|
||||
)
|
||||
.unwrap()
|
||||
|
@ -1749,7 +1751,7 @@ pub async fn get_public_rooms_filtered_route(
|
|||
room_id,
|
||||
topic: state.get(&(EventType::RoomTopic, "".to_owned())).map(|s| {
|
||||
serde_json::from_value::<
|
||||
EventJson<ruma_events::room::topic::TopicEventContent>,
|
||||
EventJson<ruma::events::room::topic::TopicEventContent>,
|
||||
>(s.content.clone())
|
||||
.unwrap()
|
||||
.deserialize()
|
||||
|
@ -1758,7 +1760,7 @@ pub async fn get_public_rooms_filtered_route(
|
|||
}),
|
||||
world_readable: state.get(&(EventType::RoomHistoryVisibility, "".to_owned())).map_or(false, |s| {
|
||||
serde_json::from_value::<
|
||||
EventJson<ruma_events::room::history_visibility::HistoryVisibilityEventContent>,
|
||||
EventJson<ruma::events::room::history_visibility::HistoryVisibilityEventContent>,
|
||||
>(s.content.clone())
|
||||
.unwrap()
|
||||
.deserialize()
|
||||
|
@ -1767,7 +1769,7 @@ pub async fn get_public_rooms_filtered_route(
|
|||
}),
|
||||
guest_can_join: state.get(&(EventType::RoomGuestAccess, "".to_owned())).map_or(false, |s| {
|
||||
serde_json::from_value::<
|
||||
EventJson<ruma_events::room::guest_access::GuestAccessEventContent>,
|
||||
EventJson<ruma::events::room::guest_access::GuestAccessEventContent>,
|
||||
>(s.content.clone())
|
||||
.unwrap()
|
||||
.deserialize()
|
||||
|
@ -1776,7 +1778,7 @@ pub async fn get_public_rooms_filtered_route(
|
|||
}),
|
||||
avatar_url: state.get(&(EventType::RoomAvatar, "".to_owned())).map(|s| {
|
||||
serde_json::from_value::<
|
||||
EventJson<ruma_events::room::avatar::AvatarEventContent>,
|
||||
EventJson<ruma::events::room::avatar::AvatarEventContent>,
|
||||
>(s.content.clone())
|
||||
.unwrap()
|
||||
.deserialize()
|
||||
|
@ -1794,10 +1796,10 @@ pub async fn get_public_rooms_filtered_route(
|
|||
&server_server::send_request(
|
||||
&db,
|
||||
"privacytools.io".to_owned(),
|
||||
ruma_federation_api::v1::get_public_rooms::Request {
|
||||
ruma::api::federation::v1::get_public_rooms::Request {
|
||||
limit: Some(20_u32.into()),
|
||||
since: None,
|
||||
room_network: ruma_federation_api::v1::get_public_rooms::RoomNetwork::Matrix,
|
||||
room_network: ruma::api::federation::v1::get_public_rooms::RoomNetwork::Matrix,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -2155,12 +2157,12 @@ pub fn sync_route(
|
|||
send_member_count = true;
|
||||
if !send_full_state && pdu.state_key == Some(user_id.to_string()) {
|
||||
let content = serde_json::from_value::<
|
||||
EventJson<ruma_events::room::member::MemberEventContent>,
|
||||
EventJson<ruma::events::room::member::MemberEventContent>,
|
||||
>(pdu.content.clone())
|
||||
.unwrap()
|
||||
.deserialize()
|
||||
.unwrap();
|
||||
if content.membership == ruma_events::room::member::MembershipState::Join {
|
||||
if content.membership == ruma::events::room::member::MembershipState::Join {
|
||||
send_full_state = true;
|
||||
// Both send_member_count and send_full_state are set. There's nothing more
|
||||
// to do
|
||||
|
@ -2191,14 +2193,14 @@ pub fn sync_route(
|
|||
.filter(|pdu| pdu.kind == EventType::RoomMember)
|
||||
.filter_map(|pdu| {
|
||||
let content = serde_json::from_value::<
|
||||
EventJson<ruma_events::room::member::MemberEventContent>,
|
||||
EventJson<ruma::events::room::member::MemberEventContent>,
|
||||
>(pdu.content.clone())
|
||||
.unwrap()
|
||||
.deserialize()
|
||||
.unwrap();
|
||||
|
||||
let current_content = serde_json::from_value::<
|
||||
EventJson<ruma_events::room::member::MemberEventContent>,
|
||||
EventJson<ruma::events::room::member::MemberEventContent>,
|
||||
>(
|
||||
state
|
||||
.get(&(
|
||||
|
@ -2218,12 +2220,12 @@ pub fn sync_route(
|
|||
// The membership was and still is invite or join
|
||||
if matches!(
|
||||
content.membership,
|
||||
ruma_events::room::member::MembershipState::Join
|
||||
| ruma_events::room::member::MembershipState::Invite
|
||||
ruma::events::room::member::MembershipState::Join
|
||||
| ruma::events::room::member::MembershipState::Invite
|
||||
) && matches!(
|
||||
current_content.membership,
|
||||
ruma_events::room::member::MembershipState::Join
|
||||
| ruma_events::room::member::MembershipState::Invite
|
||||
ruma::events::room::member::MembershipState::Join
|
||||
| ruma::events::room::member::MembershipState::Invite
|
||||
) {
|
||||
Some(pdu.state_key.unwrap())
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use crate::{utils, Error, Result};
|
||||
use ruma_events::{collections::only::Event as EduEvent, EventJson, EventType};
|
||||
use ruma_identifiers::{RoomId, UserId};
|
||||
use ruma::{
|
||||
events::{collections::only::Event as EduEvent, EventJson, EventType},
|
||||
identifiers::{RoomId, UserId},
|
||||
};
|
||||
use std::{collections::HashMap, convert::TryFrom};
|
||||
|
||||
pub struct AccountData {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::Result;
|
||||
use ruma_events::EventJson;
|
||||
use ruma::events::EventJson;
|
||||
|
||||
pub struct GlobalEdus {
|
||||
//pub globalallid_globalall: sled::Tree, // ToDevice, GlobalAllId = UserId + Count
|
||||
|
@ -10,7 +10,7 @@ impl GlobalEdus {
|
|||
/// Adds a global event which will be saved until a new event replaces it (e.g. presence updates).
|
||||
pub fn update_presence(
|
||||
&self,
|
||||
presence: ruma_events::presence::PresenceEvent,
|
||||
presence: ruma::events::presence::PresenceEvent,
|
||||
globals: &super::globals::Globals,
|
||||
) -> Result<()> {
|
||||
// Remove old entry
|
||||
|
@ -42,7 +42,8 @@ impl GlobalEdus {
|
|||
pub fn presence_since(
|
||||
&self,
|
||||
since: u64,
|
||||
) -> Result<impl Iterator<Item = Result<EventJson<ruma_events::presence::PresenceEvent>>>> {
|
||||
) -> Result<impl Iterator<Item = Result<EventJson<ruma::events::presence::PresenceEvent>>>>
|
||||
{
|
||||
let first_possible_edu = (since + 1).to_be_bytes().to_vec(); // +1 so we don't send the event at since
|
||||
|
||||
Ok(self
|
||||
|
|
|
@ -5,13 +5,13 @@ pub const COUNTER: &str = "c";
|
|||
pub struct Globals {
|
||||
pub(super) globals: sled::Tree,
|
||||
server_name: String,
|
||||
keypair: ruma_signatures::Ed25519KeyPair,
|
||||
keypair: ruma::signatures::Ed25519KeyPair,
|
||||
reqwest_client: reqwest::Client,
|
||||
}
|
||||
|
||||
impl Globals {
|
||||
pub fn load(globals: sled::Tree, server_name: String) -> Self {
|
||||
let keypair = ruma_signatures::Ed25519KeyPair::new(
|
||||
let keypair = ruma::signatures::Ed25519KeyPair::new(
|
||||
&*globals
|
||||
.update_and_fetch("keypair", utils::generate_keypair)
|
||||
.unwrap()
|
||||
|
@ -34,7 +34,7 @@ impl Globals {
|
|||
}
|
||||
|
||||
/// Returns this server's keypair.
|
||||
pub fn keypair(&self) -> &ruma_signatures::Ed25519KeyPair {
|
||||
pub fn keypair(&self) -> &ruma::signatures::Ed25519KeyPair {
|
||||
&self.keypair
|
||||
}
|
||||
|
||||
|
|
|
@ -4,15 +4,17 @@ pub use edus::RoomEdus;
|
|||
|
||||
use crate::{utils, Error, PduEvent, Result};
|
||||
use log::error;
|
||||
use ruma_events::{
|
||||
room::{
|
||||
join_rules, member,
|
||||
power_levels::{self, PowerLevelsEventContent},
|
||||
redaction,
|
||||
use ruma::{
|
||||
events::{
|
||||
room::{
|
||||
join_rules, member,
|
||||
power_levels::{self, PowerLevelsEventContent},
|
||||
redaction,
|
||||
},
|
||||
EventJson, EventType,
|
||||
},
|
||||
EventJson, EventType,
|
||||
identifiers::{EventId, RoomAliasId, RoomId, UserId},
|
||||
};
|
||||
use ruma_identifiers::{EventId, RoomAliasId, RoomId, UserId};
|
||||
use sled::IVec;
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap},
|
||||
|
@ -203,7 +205,7 @@ impl Rooms {
|
|||
users: BTreeMap::new(),
|
||||
users_default: 0.into(),
|
||||
notifications:
|
||||
ruma_events::room::power_levels::NotificationPowerLevels {
|
||||
ruma::events::room::power_levels::NotificationPowerLevels {
|
||||
room: 50.into(),
|
||||
},
|
||||
})
|
||||
|
@ -419,7 +421,7 @@ impl Rooms {
|
|||
auth_events: Vec::new(),
|
||||
redacts: redacts.clone(),
|
||||
unsigned,
|
||||
hashes: ruma_federation_api::EventHash {
|
||||
hashes: ruma::api::federation::EventHash {
|
||||
sha256: "aaa".to_owned(),
|
||||
},
|
||||
signatures: HashMap::new(),
|
||||
|
@ -428,13 +430,13 @@ impl Rooms {
|
|||
// Generate event id
|
||||
pdu.event_id = EventId::try_from(&*format!(
|
||||
"${}",
|
||||
ruma_signatures::reference_hash(&serde_json::to_value(&pdu)?)
|
||||
ruma::signatures::reference_hash(&serde_json::to_value(&pdu)?)
|
||||
.expect("ruma can calculate reference hashes")
|
||||
))
|
||||
.expect("ruma's reference hashes are correct");
|
||||
|
||||
let mut pdu_json = serde_json::to_value(&pdu)?;
|
||||
ruma_signatures::hash_and_sign_event(
|
||||
ruma::signatures::hash_and_sign_event(
|
||||
globals.server_name(),
|
||||
globals.keypair(),
|
||||
&mut pdu_json,
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use crate::{utils, Error, Result};
|
||||
use ruma_events::{collections::only::Event as EduEvent, EventJson};
|
||||
use ruma_identifiers::{RoomId, UserId};
|
||||
use ruma::{
|
||||
events::{collections::only::Event as EduEvent, EventJson},
|
||||
identifiers::{RoomId, UserId},
|
||||
};
|
||||
use std::convert::TryFrom;
|
||||
|
||||
pub struct RoomEdus {
|
||||
|
@ -190,7 +192,7 @@ impl RoomEdus {
|
|||
}
|
||||
|
||||
/// Returns an iterator over all active events (e.g. typing notifications).
|
||||
pub fn roomactives_all(&self, room_id: &RoomId) -> Result<ruma_events::typing::TypingEvent> {
|
||||
pub fn roomactives_all(&self, room_id: &RoomId) -> Result<ruma::events::typing::TypingEvent> {
|
||||
let mut prefix = room_id.to_string().as_bytes().to_vec();
|
||||
prefix.push(0xff);
|
||||
|
||||
|
@ -205,8 +207,8 @@ impl RoomEdus {
|
|||
user_ids.push(user_id?);
|
||||
}
|
||||
|
||||
Ok(ruma_events::typing::TypingEvent {
|
||||
content: ruma_events::typing::TypingEventContent { user_ids },
|
||||
Ok(ruma::events::typing::TypingEvent {
|
||||
content: ruma::events::typing::TypingEventContent { user_ids },
|
||||
room_id: None, // Can be inferred
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
use crate::{utils, Error, Result};
|
||||
use js_int::UInt;
|
||||
use ruma_client_api::r0::{
|
||||
device::Device,
|
||||
keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, OneTimeKey},
|
||||
use ruma::{
|
||||
api::client::r0::{
|
||||
device::Device,
|
||||
keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, OneTimeKey},
|
||||
},
|
||||
events::{to_device::AnyToDeviceEvent, EventJson, EventType},
|
||||
identifiers::{DeviceId, UserId},
|
||||
};
|
||||
use ruma_events::{to_device::AnyToDeviceEvent, EventJson, EventType};
|
||||
use ruma_identifiers::{DeviceId, UserId};
|
||||
use std::{collections::BTreeMap, convert::TryFrom, time::SystemTime};
|
||||
|
||||
pub struct Users {
|
||||
|
|
|
@ -22,12 +22,12 @@ pub enum Error {
|
|||
#[error("tried to parse invalid identifier")]
|
||||
RumaIdentifierError {
|
||||
#[from]
|
||||
source: ruma_identifiers::Error,
|
||||
source: ruma::identifiers::Error,
|
||||
},
|
||||
#[error("tried to parse invalid event")]
|
||||
RumaEventError {
|
||||
#[from]
|
||||
source: ruma_events::InvalidEvent,
|
||||
source: ruma::events::InvalidEvent,
|
||||
},
|
||||
#[error("could not generate image")]
|
||||
ImageError {
|
||||
|
|
14
src/pdu.rs
14
src/pdu.rs
|
@ -1,11 +1,13 @@
|
|||
use js_int::UInt;
|
||||
use ruma_events::{
|
||||
collections::all::{RoomEvent, StateEvent},
|
||||
stripped::AnyStrippedStateEvent,
|
||||
EventJson, EventType,
|
||||
use ruma::{
|
||||
api::federation::EventHash,
|
||||
events::{
|
||||
collections::all::{RoomEvent, StateEvent},
|
||||
stripped::AnyStrippedStateEvent,
|
||||
EventJson, EventType,
|
||||
},
|
||||
identifiers::{EventId, RoomId, UserId},
|
||||
};
|
||||
use ruma_federation_api::EventHash;
|
||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
use std::collections::HashMap;
|
||||
|
|
|
@ -7,8 +7,7 @@ use rocket::{
|
|||
Outcome::*,
|
||||
Request, State,
|
||||
};
|
||||
use ruma_api::Endpoint;
|
||||
use ruma_identifiers::UserId;
|
||||
use ruma::{api::Endpoint, identifiers::UserId};
|
||||
use std::{convert::TryInto, io::Cursor, ops::Deref};
|
||||
use tokio::io::AsyncReadExt;
|
||||
|
||||
|
@ -109,7 +108,7 @@ impl<T> Deref for Ruma<T> {
|
|||
}
|
||||
|
||||
/// This struct converts ruma responses into rocket http responses.
|
||||
pub struct MatrixResult<T, E = ruma_client_api::Error>(pub std::result::Result<T, E>);
|
||||
pub struct MatrixResult<T, E = ruma::api::client::Error>(pub std::result::Result<T, E>);
|
||||
|
||||
impl<T, E> TryInto<http::Response<Vec<u8>>> for MatrixResult<T, E>
|
||||
where
|
||||
|
|
|
@ -2,9 +2,9 @@ use crate::{Database, MatrixResult};
|
|||
use http::header::{HeaderValue, AUTHORIZATION};
|
||||
use log::error;
|
||||
use rocket::{get, response::content::Json, State};
|
||||
use ruma_api::Endpoint;
|
||||
use ruma_client_api::error::Error;
|
||||
use ruma_federation_api::discovery::{
|
||||
use ruma::api::Endpoint;
|
||||
use ruma::api::client::error::Error;
|
||||
use ruma::api::federation::discovery::{
|
||||
get_server_keys::v2 as get_server_keys, get_server_version::v1 as get_server_version,
|
||||
};
|
||||
use serde_json::json;
|
||||
|
@ -61,7 +61,7 @@ pub async fn send_request<T: Endpoint>(
|
|||
request_map.insert("destination".to_owned(), destination.into());
|
||||
|
||||
let mut request_json = request_map.into();
|
||||
ruma_signatures::sign_json(
|
||||
ruma::signatures::sign_json(
|
||||
db.globals.server_name(),
|
||||
db.globals.keypair(),
|
||||
&mut request_json,
|
||||
|
@ -168,7 +168,7 @@ pub fn get_server_keys(db: State<'_, Database>) -> Json<String> {
|
|||
.body(),
|
||||
)
|
||||
.unwrap();
|
||||
ruma_signatures::sign_json(
|
||||
ruma::signatures::sign_json(
|
||||
db.globals.server_name(),
|
||||
db.globals.keypair(),
|
||||
&mut response,
|
||||
|
|
|
@ -29,7 +29,7 @@ pub fn increment(old: Option<&[u8]>) -> Option<Vec<u8>> {
|
|||
pub fn generate_keypair(old: Option<&[u8]>) -> Option<Vec<u8>> {
|
||||
Some(
|
||||
old.map(|s| s.to_vec())
|
||||
.unwrap_or_else(|| ruma_signatures::Ed25519KeyPair::generate().unwrap()),
|
||||
.unwrap_or_else(|| ruma::signatures::Ed25519KeyPair::generate().unwrap()),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue