Small refactor so we don't duplicate user_id creation.

This commit is contained in:
Denis Kasak 2020-06-10 12:01:01 +02:00
parent 4c184a30a2
commit 5868c72662

View file

@ -341,15 +341,12 @@ impl Room {
}
fn add_member(&mut self, event: &MemberEvent) -> bool {
if self
.members
.contains_key(&UserId::try_from(event.state_key.as_str()).unwrap())
{
let new_member = RoomMember::new(event);
if self.members.contains_key(&new_member.user_id) {
return false;
}
let new_member = RoomMember::new(event);
// Find all users that share the same display name as the joining user.
let users_with_same_name: Vec<UserId> = self
.members
@ -487,6 +484,7 @@ impl Room {
} else {
return false;
};
if let Some(member) = self.members.get_mut(&user) {
member.update_member(event)
} else {