Remove `is_direct` flag from Join event

When I was investigating the DM issue, I found that join event contained
the `is_direct` flag. According to the spec, this flag should only be
set on "invite" events, but not on join.

Other homeservers do not have this flag on join.
next
Guillem Nieto 2020-06-19 12:19:07 +02:00 committed by timokoesters
parent a49a572d76
commit 8f06d0258a
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
1 changed files with 7 additions and 28 deletions

View File

@ -1390,34 +1390,13 @@ pub fn join_room_by_id_route(
// TODO: Ask a remote server if we don't have this room // TODO: Ask a remote server if we don't have this room
let event = db let event = member::MemberEventContent {
.rooms membership: member::MembershipState::Join,
.room_state_get(&body.room_id, &EventType::RoomMember, &user_id.to_string())? displayname: db.users.displayname(&user_id)?,
.map_or_else( avatar_url: db.users.avatar_url(&user_id)?,
|| { is_direct: None,
// There was no existing membership event third_party_invite: None,
Ok::<_, Error>(member::MemberEventContent { };
membership: member::MembershipState::Join,
displayname: db.users.displayname(&user_id)?,
avatar_url: db.users.avatar_url(&user_id)?,
is_direct: None,
third_party_invite: None,
})
},
|pdu| {
// We change the existing membership event
let mut event = serde_json::from_value::<EventJson<member::MemberEventContent>>(
pdu.content.clone(),
)
.map_err(|_| Error::bad_database("Invalid member event in db."))?
.deserialize()
.map_err(|_| Error::bad_database("Invalid member event in db."))?;
event.membership = member::MembershipState::Join;
event.displayname = db.users.displayname(&user_id)?;
event.avatar_url = db.users.avatar_url(&user_id)?;
Ok(event)
},
)?;
db.rooms.append_pdu( db.rooms.append_pdu(
body.room_id.clone(), body.room_id.clone(),