Upgrade ruma
parent
0bdcc0fbf9
commit
15540e84e3
|
@ -20,7 +20,6 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
result::Result as StdResult,
|
result::Result as StdResult,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::SystemTime,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
|
@ -49,7 +48,7 @@ use matrix_sdk_common::{
|
||||||
instant::Instant,
|
instant::Instant,
|
||||||
locks::RwLock,
|
locks::RwLock,
|
||||||
push::{Action, PushConditionRoomCtx, Ruleset},
|
push::{Action, PushConditionRoomCtx, Ruleset},
|
||||||
Raw, UInt,
|
MilliSecondsSinceUnixEpoch, Raw, UInt,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
use matrix_sdk_crypto::{
|
use matrix_sdk_crypto::{
|
||||||
|
@ -100,8 +99,7 @@ pub struct AdditionalUnsignedData {
|
||||||
pub fn hoist_and_deserialize_state_event(
|
pub fn hoist_and_deserialize_state_event(
|
||||||
event: &Raw<AnySyncStateEvent>,
|
event: &Raw<AnySyncStateEvent>,
|
||||||
) -> StdResult<AnySyncStateEvent, serde_json::Error> {
|
) -> StdResult<AnySyncStateEvent, serde_json::Error> {
|
||||||
let prev_content =
|
let prev_content = event.deserialize_as::<AdditionalEventData>()?.unsigned.prev_content;
|
||||||
serde_json::from_str::<AdditionalEventData>(event.json().get())?.unsigned.prev_content;
|
|
||||||
|
|
||||||
let mut ev = event.deserialize()?;
|
let mut ev = event.deserialize()?;
|
||||||
|
|
||||||
|
@ -117,8 +115,7 @@ pub fn hoist_and_deserialize_state_event(
|
||||||
fn hoist_member_event(
|
fn hoist_member_event(
|
||||||
event: &Raw<StateEvent<MemberEventContent>>,
|
event: &Raw<StateEvent<MemberEventContent>>,
|
||||||
) -> StdResult<StateEvent<MemberEventContent>, serde_json::Error> {
|
) -> StdResult<StateEvent<MemberEventContent>, serde_json::Error> {
|
||||||
let prev_content =
|
let prev_content = event.deserialize_as::<AdditionalEventData>()?.unsigned.prev_content;
|
||||||
serde_json::from_str::<AdditionalEventData>(event.json().get())?.unsigned.prev_content;
|
|
||||||
|
|
||||||
let mut e = event.deserialize()?;
|
let mut e = event.deserialize()?;
|
||||||
|
|
||||||
|
@ -132,7 +129,8 @@ fn hoist_member_event(
|
||||||
fn hoist_room_event_prev_content(
|
fn hoist_room_event_prev_content(
|
||||||
event: &Raw<AnySyncRoomEvent>,
|
event: &Raw<AnySyncRoomEvent>,
|
||||||
) -> StdResult<AnySyncRoomEvent, serde_json::Error> {
|
) -> StdResult<AnySyncRoomEvent, serde_json::Error> {
|
||||||
let prev_content = serde_json::from_str::<AdditionalEventData>(event.json().get())
|
let prev_content = event
|
||||||
|
.deserialize_as::<AdditionalEventData>()
|
||||||
.map(|more_unsigned| more_unsigned.unsigned)
|
.map(|more_unsigned| more_unsigned.unsigned)
|
||||||
.map(|additional| additional.prev_content)?
|
.map(|additional| additional.prev_content)?
|
||||||
.and_then(|p| p.deserialize().ok());
|
.and_then(|p| p.deserialize().ok());
|
||||||
|
@ -515,7 +513,7 @@ impl BaseClient {
|
||||||
event.event.clone(),
|
event.event.clone(),
|
||||||
false,
|
false,
|
||||||
room_id.clone(),
|
room_id.clone(),
|
||||||
SystemTime::now(),
|
MilliSecondsSinceUnixEpoch::now(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -681,7 +681,7 @@ impl StateStore for SledStore {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use std::{convert::TryFrom, time::SystemTime};
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
use matrix_sdk_common::{
|
use matrix_sdk_common::{
|
||||||
events::{
|
events::{
|
||||||
|
@ -692,7 +692,7 @@ mod test {
|
||||||
AnySyncStateEvent, EventType, Unsigned,
|
AnySyncStateEvent, EventType, Unsigned,
|
||||||
},
|
},
|
||||||
identifiers::{room_id, user_id, EventId, UserId},
|
identifiers::{room_id, user_id, EventId, UserId},
|
||||||
Raw,
|
MilliSecondsSinceUnixEpoch, Raw,
|
||||||
};
|
};
|
||||||
use matrix_sdk_test::async_test;
|
use matrix_sdk_test::async_test;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
@ -733,7 +733,7 @@ mod test {
|
||||||
event_id: EventId::try_from("$h29iv0s8:example.com").unwrap(),
|
event_id: EventId::try_from("$h29iv0s8:example.com").unwrap(),
|
||||||
content,
|
content,
|
||||||
sender: user_id(),
|
sender: user_id(),
|
||||||
origin_server_ts: SystemTime::now(),
|
origin_server_ts: MilliSecondsSinceUnixEpoch::now(),
|
||||||
state_key: user_id(),
|
state_key: user_id(),
|
||||||
prev_content: None,
|
prev_content: None,
|
||||||
unsigned: Unsigned::default(),
|
unsigned: Unsigned::default(),
|
||||||
|
|
|
@ -22,7 +22,7 @@ async-trait = "0.1.42"
|
||||||
[dependencies.ruma]
|
[dependencies.ruma]
|
||||||
version = "0.0.3"
|
version = "0.0.3"
|
||||||
git = "https://github.com/ruma/ruma"
|
git = "https://github.com/ruma/ruma"
|
||||||
rev = "3bdead1cf207e3ab9c8fcbfc454c054c726ba6f5"
|
rev = "e1ab817e0bef78cb8241d6d3c1ced7d6b414c7f6"
|
||||||
features = ["client-api-c", "compat", "unstable-pre-spec"]
|
features = ["client-api-c", "compat", "unstable-pre-spec"]
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{collections::BTreeMap, convert::TryFrom, time::SystemTime};
|
use std::{collections::BTreeMap, convert::TryFrom};
|
||||||
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::r0::sync::sync_events::{
|
api::client::r0::sync::sync_events::{
|
||||||
|
@ -22,6 +22,7 @@ use super::{
|
||||||
SyncStateEvent, Unsigned,
|
SyncStateEvent, Unsigned,
|
||||||
},
|
},
|
||||||
identifiers::{DeviceKeyAlgorithm, EventId, RoomId, UserId},
|
identifiers::{DeviceKeyAlgorithm, EventId, RoomId, UserId},
|
||||||
|
MilliSecondsSinceUnixEpoch,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A change in ambiguity of room members that an `m.room.member` event
|
/// A change in ambiguity of room members that an `m.room.member` event
|
||||||
|
@ -249,7 +250,7 @@ impl Timeline {
|
||||||
pub struct MemberEvent {
|
pub struct MemberEvent {
|
||||||
pub content: MemberEventContent,
|
pub content: MemberEventContent,
|
||||||
pub event_id: EventId,
|
pub event_id: EventId,
|
||||||
pub origin_server_ts: SystemTime,
|
pub origin_server_ts: MilliSecondsSinceUnixEpoch,
|
||||||
pub prev_content: Option<MemberEventContent>,
|
pub prev_content: Option<MemberEventContent>,
|
||||||
pub sender: UserId,
|
pub sender: UserId,
|
||||||
pub state_key: UserId,
|
pub state_key: UserId,
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub use ruma::{
|
||||||
},
|
},
|
||||||
assign, directory, encryption, events, identifiers, int, presence, push, receipt,
|
assign, directory, encryption, events, identifiers, int, presence, push, receipt,
|
||||||
serde::{CanonicalJsonValue, Raw},
|
serde::{CanonicalJsonValue, Raw},
|
||||||
thirdparty, uint, Int, Outgoing, UInt,
|
thirdparty, uint, Int, MilliSecondsSinceUnixEpoch, Outgoing, SecondsSinceUnixEpoch, UInt,
|
||||||
};
|
};
|
||||||
pub use uuid;
|
pub use uuid;
|
||||||
|
|
||||||
|
|
|
@ -1204,7 +1204,6 @@ pub(crate) mod test {
|
||||||
collections::BTreeMap,
|
collections::BTreeMap,
|
||||||
convert::{TryFrom, TryInto},
|
convert::{TryFrom, TryInto},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::SystemTime,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use http::Response;
|
use http::Response;
|
||||||
|
@ -1221,7 +1220,7 @@ pub(crate) mod test {
|
||||||
identifiers::{
|
identifiers::{
|
||||||
event_id, room_id, user_id, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId,
|
event_id, room_id, user_id, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId,
|
||||||
},
|
},
|
||||||
IncomingResponse, Raw,
|
IncomingResponse, MilliSecondsSinceUnixEpoch, Raw,
|
||||||
};
|
};
|
||||||
use matrix_sdk_test::test_json;
|
use matrix_sdk_test::test_json;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
@ -1668,7 +1667,7 @@ pub(crate) mod test {
|
||||||
|
|
||||||
let event = SyncMessageEvent {
|
let event = SyncMessageEvent {
|
||||||
event_id: event_id!("$xxxxx:example.org"),
|
event_id: event_id!("$xxxxx:example.org"),
|
||||||
origin_server_ts: SystemTime::now(),
|
origin_server_ts: MilliSecondsSinceUnixEpoch::now(),
|
||||||
sender: alice.user_id().clone(),
|
sender: alice.user_id().clone(),
|
||||||
content: encrypted_content,
|
content: encrypted_content,
|
||||||
unsigned: Unsigned::default(),
|
unsigned: Unsigned::default(),
|
||||||
|
|
|
@ -12,12 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use std::{
|
use std::{collections::BTreeMap, convert::TryFrom, fmt, mem, sync::Arc};
|
||||||
collections::BTreeMap,
|
|
||||||
convert::{TryFrom, TryInto},
|
|
||||||
fmt, mem,
|
|
||||||
sync::Arc,
|
|
||||||
};
|
|
||||||
|
|
||||||
use matrix_sdk_common::{
|
use matrix_sdk_common::{
|
||||||
events::{
|
events::{
|
||||||
|
@ -310,13 +305,7 @@ impl InboundGroupSession {
|
||||||
let mut decrypted_value = serde_json::from_str::<Value>(&plaintext)?;
|
let mut decrypted_value = serde_json::from_str::<Value>(&plaintext)?;
|
||||||
let decrypted_object = decrypted_value.as_object_mut().ok_or(EventError::NotAnObject)?;
|
let decrypted_object = decrypted_value.as_object_mut().ok_or(EventError::NotAnObject)?;
|
||||||
|
|
||||||
// TODO better number conversion here.
|
let server_ts: i64 = event.origin_server_ts.0.into();
|
||||||
let server_ts = event
|
|
||||||
.origin_server_ts
|
|
||||||
.duration_since(std::time::SystemTime::UNIX_EPOCH)
|
|
||||||
.unwrap_or_default()
|
|
||||||
.as_millis();
|
|
||||||
let server_ts: i64 = server_ts.try_into().unwrap_or_default();
|
|
||||||
|
|
||||||
decrypted_object.insert("sender".to_owned(), event.sender.to_string().into());
|
decrypted_object.insert("sender".to_owned(), event.sender.to_string().into());
|
||||||
decrypted_object.insert("event_id".to_owned(), event.event_id.to_string().into());
|
decrypted_object.insert("event_id".to_owned(), event.event_id.to_string().into());
|
||||||
|
|
|
@ -436,12 +436,13 @@ struct Passive {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use std::{convert::TryFrom, time::SystemTime};
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
use matrix_sdk_common::{
|
use matrix_sdk_common::{
|
||||||
api::r0::message::send_message_event::Response as RoomMessageResponse,
|
api::r0::message::send_message_event::Response as RoomMessageResponse,
|
||||||
events::{SyncMessageEvent, Unsigned},
|
events::{SyncMessageEvent, Unsigned},
|
||||||
identifiers::{event_id, room_id, DeviceIdBox, UserId},
|
identifiers::{event_id, room_id, DeviceIdBox, UserId},
|
||||||
|
MilliSecondsSinceUnixEpoch,
|
||||||
};
|
};
|
||||||
use matrix_sdk_test::async_test;
|
use matrix_sdk_test::async_test;
|
||||||
|
|
||||||
|
@ -566,7 +567,7 @@ mod test {
|
||||||
content: c,
|
content: c,
|
||||||
event_id: event_id.clone(),
|
event_id: event_id.clone(),
|
||||||
sender: bob_id(),
|
sender: bob_id(),
|
||||||
origin_server_ts: SystemTime::now(),
|
origin_server_ts: MilliSecondsSinceUnixEpoch::now(),
|
||||||
unsigned: Unsigned::default(),
|
unsigned: Unsigned::default(),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue