Small refactor so we don't duplicate user_id creation.

master
Denis Kasak 2020-06-10 12:01:01 +02:00
parent 4c184a30a2
commit 5868c72662
1 changed files with 4 additions and 6 deletions

View File

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