diff --git a/src/async_client.rs b/src/async_client.rs index ef6dd300..ed1831f7 100644 --- a/src/async_client.rs +++ b/src/async_client.rs @@ -533,6 +533,7 @@ impl AsyncClient { } // look at AccountData to further cut down users by collecting ignored users + // TODO actually use the ignored users for account_data in &room.account_data.events { let mut client = self.base_client.write().await; if let EventResult::Ok(e) = account_data { diff --git a/src/base_client.rs b/src/base_client.rs index 23d501ac..e6f15f2d 100644 --- a/src/base_client.rs +++ b/src/base_client.rs @@ -26,7 +26,7 @@ use crate::events::presence::PresenceEvent; // `NonRoomEvent` is what it is aliased as use crate::events::collections::only::Event as NonRoomEvent; use crate::events::ignored_user_list::IgnoredUserListEvent; -use crate::events::push_rules::{ Ruleset, PushRulesEvent}; +use crate::events::push_rules::{PushRulesEvent, Ruleset}; use crate::events::room::{ aliases::AliasesEvent, canonical_alias::CanonicalAliasEvent, @@ -81,7 +81,8 @@ impl CurrentRoom { pub(crate) fn update(&mut self, room_id: &str, event: &PresenceEvent) { self.last_active = event.content.last_active_ago; - self.current_room_id = Some(RoomId::try_from(room_id).expect("room id failed CurrentRoom::update")); + self.current_room_id = + Some(RoomId::try_from(room_id).expect("room id failed CurrentRoom::update")); } } @@ -209,10 +210,22 @@ impl Client { /// Returns true if the room name changed, false otherwise. pub(crate) fn handle_ignored_users(&mut self, event: &IgnoredUserListEvent) -> bool { // TODO use actual UserId instead of string? - if self.ignored_users == event.content.ignored_users.iter().map(|u| u.to_string()).collect::>() { + if self.ignored_users + == event + .content + .ignored_users + .iter() + .map(|u| u.to_string()) + .collect::>() + { false } else { - self.ignored_users = event.content.ignored_users.iter().map(|u| u.to_string()).collect(); + self.ignored_users = event + .content + .ignored_users + .iter() + .map(|u| u.to_string()) + .collect(); true } } @@ -304,7 +317,11 @@ impl Client { /// /// * `event` - The event that should be handled by the client. pub fn receive_presence_event(&mut self, room_id: &str, event: &PresenceEvent) -> bool { - let user_id = &self.session.as_ref().expect("to receive events you must be logged in").user_id; + let user_id = &self + .session + .as_ref() + .expect("to receive events you must be logged in") + .user_id; if self.current_room_id.comes_after(user_id, event) { self.current_room_id.update(room_id, event); } diff --git a/src/models/mod.rs b/src/models/mod.rs index cbc7422e..8fbc08d4 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -1,6 +1,5 @@ mod room; mod room_member; -mod room_state; mod user; pub use room::{Room, RoomName}; diff --git a/src/models/room_state.rs b/src/models/room_state.rs deleted file mode 100644 index f4404b09..00000000 --- a/src/models/room_state.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2020 Damir Jelić -// Copyright 2020 The Matrix.org Foundation C.I.C. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. diff --git a/src/models/user.rs b/src/models/user.rs index 786bad6e..37c123a1 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -128,7 +128,7 @@ impl User { *self = User { display_name: displayname.clone(), avatar_url: avatar_url.clone(), - presence: Some(presence.clone()), + presence: Some(*presence), status_msg: status_msg.clone(), last_active_ago: *last_active_ago, currently_active: *currently_active,