fix: send correct membership events when joining / creating rooms
This commit is contained in:
parent
8df2a1a072
commit
43478a5870
2 changed files with 14 additions and 11 deletions
|
@ -965,7 +965,7 @@ pub fn create_room_route(
|
||||||
.join(
|
.join(
|
||||||
&room_id,
|
&room_id,
|
||||||
&user_id,
|
&user_id,
|
||||||
db.users.displayname(&user_id).unwrap(),
|
&db.users,
|
||||||
&db.globals,
|
&db.globals,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -1072,7 +1072,7 @@ pub fn join_room_by_id_route(
|
||||||
.join(
|
.join(
|
||||||
&body.room_id,
|
&body.room_id,
|
||||||
&user_id,
|
&user_id,
|
||||||
db.users.displayname(&user_id).unwrap(),
|
&db.users,
|
||||||
&db.globals,
|
&db.globals,
|
||||||
)
|
)
|
||||||
.is_ok()
|
.is_ok()
|
||||||
|
@ -1119,7 +1119,7 @@ pub fn join_room_by_id_or_alias_route(
|
||||||
.join(
|
.join(
|
||||||
&room_id,
|
&room_id,
|
||||||
&user_id,
|
&user_id,
|
||||||
db.users.displayname(&user_id).unwrap(),
|
&db.users,
|
||||||
&db.globals,
|
&db.globals,
|
||||||
)
|
)
|
||||||
.is_ok()
|
.is_ok()
|
||||||
|
|
|
@ -353,7 +353,7 @@ impl Rooms {
|
||||||
&self,
|
&self,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
displayname: Option<String>,
|
users: &super::users::Users,
|
||||||
globals: &super::globals::Globals,
|
globals: &super::globals::Globals,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if !self.exists(room_id)? {
|
if !self.exists(room_id)? {
|
||||||
|
@ -374,19 +374,22 @@ impl Rooms {
|
||||||
self.roomuserid_invited.remove(&roomuser_id)?;
|
self.roomuserid_invited.remove(&roomuser_id)?;
|
||||||
self.userroomid_left.remove(&userroom_id)?;
|
self.userroomid_left.remove(&userroom_id)?;
|
||||||
|
|
||||||
let mut content = json!({"membership": "join"});
|
let mut json = serde_json::Map::new();
|
||||||
if let Some(displayname) = displayname {
|
json.insert("membership".to_owned(), "join".into());
|
||||||
content
|
|
||||||
.as_object_mut()
|
if let Some(displayname) = users.displayname(&user_id).unwrap() {
|
||||||
.unwrap()
|
json.insert("displayname".to_owned(), displayname.into());
|
||||||
.insert("displayname".to_owned(), displayname.into());
|
}
|
||||||
|
|
||||||
|
if let Some(avatar_url) = users.avatar_url(&user_id).unwrap() {
|
||||||
|
json.insert("avatar_url".to_owned(), avatar_url.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
self.append_pdu(
|
self.append_pdu(
|
||||||
room_id.clone(),
|
room_id.clone(),
|
||||||
user_id.clone(),
|
user_id.clone(),
|
||||||
EventType::RoomMember,
|
EventType::RoomMember,
|
||||||
content,
|
json.into(),
|
||||||
None,
|
None,
|
||||||
Some(user_id.to_string()),
|
Some(user_id.to_string()),
|
||||||
globals,
|
globals,
|
||||||
|
|
Loading…
Add table
Reference in a new issue