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