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.
This commit is contained in:
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,
};
use super::{Client, ClientConfig, Session, SyncSettings, Url};
use crate::events::room::member::MembershipState;
use crate::events::room::message::TextMessageEventContent;
use crate::identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId};

View file

@ -1845,9 +1845,9 @@ impl BaseClient {
#[cfg(test)]
mod test {
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_test::{async_test, test_json, EventBuilder, EventsFile};
use matrix_sdk_test::{async_test, test_json, EventBuilder, EventsJson};
use serde_json::json;
use std::convert::TryFrom;

View file

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

View file

@ -369,7 +369,17 @@ impl Room {
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.
let disambiguations = self.disambiguation_updates(&new_member, MemberDirection::Entering);

View file

@ -1,5 +1,5 @@
[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"
edition = "2018"
homepage = "https://github.com/matrix-org/matrix-rust-sdk"

View file

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