Switch to the ruma meta-crate

This commit is contained in:
Jonas Platte 2020-06-05 18:19:26 +02:00
parent 3a5b292f22
commit 7526fd8602
No known key found for this signature in database
GPG key ID: 7D261D771D915378
14 changed files with 197 additions and 202 deletions

View file

@ -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 {

View file

@ -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

View file

@ -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
}

View file

@ -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,

View file

@ -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
})
}

View file

@ -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 {