cargo fmt
parent
7d9a699d62
commit
9e48b7172b
|
@ -909,13 +909,11 @@ impl Room {
|
||||||
&mut self,
|
&mut self,
|
||||||
target_member: &UserId,
|
target_member: &UserId,
|
||||||
event: &StateEventStub<MemberEventContent>,
|
event: &StateEventStub<MemberEventContent>,
|
||||||
change: MembershipChange
|
change: MembershipChange,
|
||||||
) -> (bool, HashMap<UserId, bool>) {
|
) -> (bool, HashMap<UserId, bool>) {
|
||||||
let member = self.get_member(target_member);
|
let member = self.get_member(target_member);
|
||||||
let member = match member {
|
let member = match member {
|
||||||
Some(member) => {
|
Some(member) => member,
|
||||||
member
|
|
||||||
}
|
|
||||||
|
|
||||||
None => {
|
None => {
|
||||||
debug!("update_member_profile [{}]: Got a profile update for user {} but he's not a room member",
|
debug!("update_member_profile [{}]: Got a profile update for user {} but he's not a room member",
|
||||||
|
@ -928,25 +926,32 @@ impl Room {
|
||||||
let new_name = event.content.displayname.clone();
|
let new_name = event.content.displayname.clone();
|
||||||
|
|
||||||
match change {
|
match change {
|
||||||
MembershipChange::ProfileChanged { displayname_changed, avatar_url_changed } => {
|
MembershipChange::ProfileChanged {
|
||||||
|
displayname_changed,
|
||||||
|
avatar_url_changed,
|
||||||
|
} => {
|
||||||
if displayname_changed {
|
if displayname_changed {
|
||||||
debug!("update_member_profile [{}]: {} changed display name from {:#?} to {:#?}",
|
debug!(
|
||||||
|
"update_member_profile [{}]: {} changed display name from {:#?} to {:#?}",
|
||||||
self.room_id, target_member, old_name, &new_name
|
self.room_id, target_member, old_name, &new_name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if avatar_url_changed {
|
if avatar_url_changed {
|
||||||
debug!("update_member_profile [{}]: {} changed avatar URL from {:#?} to {:#?}",
|
debug!(
|
||||||
|
"update_member_profile [{}]: {} changed avatar URL from {:#?} to {:#?}",
|
||||||
self.room_id, target_member, &member.avatar_url, &new_name
|
self.room_id, target_member, &member.avatar_url, &new_name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
error!("update_member_profile [{}]: got a ProfileChanged but nothing changed",
|
error!(
|
||||||
self.room_id);
|
"update_member_profile [{}]: got a ProfileChanged but nothing changed",
|
||||||
|
self.room_id
|
||||||
|
);
|
||||||
return (false, HashMap::new());
|
return (false, HashMap::new());
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let disambiguations =
|
let disambiguations =
|
||||||
|
@ -1007,8 +1012,7 @@ impl Room {
|
||||||
}
|
}
|
||||||
|
|
||||||
if max_power > int!(0) {
|
if max_power > int!(0) {
|
||||||
member.power_level_norm =
|
member.power_level_norm = Some((member.power_level.unwrap() * int!(100)) / max_power);
|
||||||
Some((member.power_level.unwrap() * int!(100)) / max_power);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
changed
|
changed
|
||||||
|
@ -1045,15 +1049,16 @@ impl Describe for MembershipChange {
|
||||||
Self::InvitationRejected => "rejected the invitation to",
|
Self::InvitationRejected => "rejected the invitation to",
|
||||||
Self::InvitationRevoked => "got their invitation revoked from",
|
Self::InvitationRevoked => "got their invitation revoked from",
|
||||||
Self::Left => "left",
|
Self::Left => "left",
|
||||||
Self::ProfileChanged { displayname_changed, avatar_url_changed } => {
|
Self::ProfileChanged {
|
||||||
match (*displayname_changed, *avatar_url_changed) {
|
displayname_changed,
|
||||||
|
avatar_url_changed,
|
||||||
|
} => match (*displayname_changed, *avatar_url_changed) {
|
||||||
(true, true) => "changed their displayname and avatar",
|
(true, true) => "changed their displayname and avatar",
|
||||||
(true, false) => "changed their displayname",
|
(true, false) => "changed their displayname",
|
||||||
(false, true) => "changed their avatar",
|
(false, true) => "changed their avatar",
|
||||||
_ => {
|
_ => {
|
||||||
error!("Got ProfileChanged but nothing changed");
|
error!("Got ProfileChanged but nothing changed");
|
||||||
"impossible: changed nothing in their profile"
|
"impossible: changed nothing in their profile"
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Self::None => "did nothing in",
|
Self::None => "did nothing in",
|
||||||
|
@ -1386,10 +1391,7 @@ mod test {
|
||||||
.build_sync_response();
|
.build_sync_response();
|
||||||
|
|
||||||
let mut member2_rejoins_when_invited_sync_response = event_builder
|
let mut member2_rejoins_when_invited_sync_response = event_builder
|
||||||
.add_custom_joined_event(
|
.add_custom_joined_event(&room_id, member1_invites_member2_event)
|
||||||
&room_id,
|
|
||||||
member1_invites_member2_event,
|
|
||||||
)
|
|
||||||
.add_custom_joined_event(&room_id, member2_join_event)
|
.add_custom_joined_event(&room_id, member2_join_event)
|
||||||
.build_sync_response();
|
.build_sync_response();
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ pub mod sync;
|
||||||
|
|
||||||
pub use events::{
|
pub use events::{
|
||||||
ALIAS, ALIASES, EVENT_ID, KEYS_QUERY, KEYS_UPLOAD, LOGIN, LOGIN_RESPONSE_ERR, LOGOUT, MEMBER,
|
ALIAS, ALIASES, EVENT_ID, KEYS_QUERY, KEYS_UPLOAD, LOGIN, LOGIN_RESPONSE_ERR, LOGOUT, MEMBER,
|
||||||
MEMBER_NAME_CHANGE, MESSAGE_EDIT, MESSAGE_TEXT, NAME, POWER_LEVELS, PRESENCE, PUBLIC_ROOMS, REACTION, REDACTED,
|
MEMBER_NAME_CHANGE, MESSAGE_EDIT, MESSAGE_TEXT, NAME, POWER_LEVELS, PRESENCE, PUBLIC_ROOMS,
|
||||||
REDACTED_INVALID, REDACTED_STATE, REDACTION, REGISTRATION_RESPONSE_ERR, ROOM_ID, ROOM_MESSAGES,
|
REACTION, REDACTED, REDACTED_INVALID, REDACTED_STATE, REDACTION, REGISTRATION_RESPONSE_ERR,
|
||||||
TYPING,
|
ROOM_ID, ROOM_MESSAGES, TYPING,
|
||||||
};
|
};
|
||||||
pub use sync::{DEFAULT_SYNC_SUMMARY, INVITE_SYNC, LEAVE_SYNC, LEAVE_SYNC_EVENT, MORE_SYNC, SYNC};
|
pub use sync::{DEFAULT_SYNC_SUMMARY, INVITE_SYNC, LEAVE_SYNC, LEAVE_SYNC_EVENT, MORE_SYNC, SYNC};
|
||||||
|
|
Loading…
Reference in New Issue