matrix-sdk-base: Use new accessor methods for models/message.rs

ruma now has field access methods for all of the Any*Event enums use
them for MessageWrapper's AnyMessageEventStub contents.
master
Devin R 2020-06-24 20:30:53 -04:00
parent 68822861d5
commit b83b9dc59d
6 changed files with 16 additions and 8 deletions

View File

@ -1514,7 +1514,6 @@ mod test {
set_read_marker, Invite3pid, MessageEventContent, set_read_marker, Invite3pid, MessageEventContent,
}; };
use super::{Client, ClientConfig, Session, SyncSettings, Url}; use super::{Client, ClientConfig, Session, SyncSettings, Url};
use crate::events::room::member::MembershipState;
use crate::events::room::message::TextMessageEventContent; use crate::events::room::message::TextMessageEventContent;
use crate::identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId}; use crate::identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId};

View File

@ -1845,9 +1845,9 @@ impl BaseClient {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::identifiers::{RoomId, UserId}; use crate::identifiers::{RoomId, UserId};
use crate::{events::AnyRoomEventStub, BaseClient, Session}; use crate::{BaseClient, Session};
use matrix_sdk_common_macros::async_trait; use matrix_sdk_common_macros::async_trait;
use matrix_sdk_test::{async_test, test_json, EventBuilder, EventsFile}; use matrix_sdk_test::{async_test, test_json, EventBuilder, EventsJson};
use serde_json::json; use serde_json::json;
use std::convert::TryFrom; use std::convert::TryFrom;

View File

@ -461,8 +461,7 @@ mod test {
async fn on_presence_event(&self, _: SyncRoom, _: &PresenceEvent) { async fn on_presence_event(&self, _: SyncRoom, _: &PresenceEvent) {
self.0.lock().await.push("presence event".to_string()) self.0.lock().await.push("presence event".to_string())
} }
async fn on_unrecognized_event(&self, _: SyncRoom, event: &CustomOrRawEvent<'_>) { async fn on_unrecognized_event(&self, _: SyncRoom, _: &CustomOrRawEvent<'_>) {
println!("{:#?}", event);
self.0.lock().await.push("unrecognized event".to_string()) self.0.lock().await.push("unrecognized event".to_string())
} }
} }

View File

@ -369,7 +369,17 @@ impl Room {
return false; return false;
} }
let member = RoomMember::new(event, room_id); match event.membership_change() {
MembershipChange::Joined => self
.joined_members
.insert(new_member.user_id.clone(), new_member.clone()),
MembershipChange::Invited => self
.invited_members
.insert(new_member.user_id.clone(), new_member.clone()),
_ => {
panic!("Room::add_member called on an event that is neither a join nor an invite.")
}
};
// Perform display name disambiguations, if necessary. // Perform display name disambiguations, if necessary.
let disambiguations = self.disambiguation_updates(&new_member, MemberDirection::Entering); let disambiguations = self.disambiguation_updates(&new_member, MemberDirection::Entering);

View File

@ -1,5 +1,5 @@
[package] [package]
authors = ["Damir Jelić <poljar@termina.org.uk"] authors = ["Damir Jelić <poljar@termina.org.uk>"]
description = "Collection of common types used in the matrix-sdk" description = "Collection of common types used in the matrix-sdk"
edition = "2018" edition = "2018"
homepage = "https://github.com/matrix-org/matrix-rust-sdk" homepage = "https://github.com/matrix-org/matrix-rust-sdk"

View File

@ -1,5 +1,5 @@
[package] [package]
authors = ["Damir Jelić <poljar@termina.org.uk"] authors = ["Damir Jelić <poljar@termina.org.uk>"]
description = "Helpers to write tests for the Matrix SDK" description = "Helpers to write tests for the Matrix SDK"
edition = "2018" edition = "2018"
homepage = "https://github.com/matrix-org/matrix-rust-sdk" homepage = "https://github.com/matrix-org/matrix-rust-sdk"