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
let event = db
.rooms
.room_state_get(&body.room_id, &EventType::RoomMember, &user_id.to_string())?
.map_or_else(
|| {
// There was no existing membership event
Ok::<_, Error>(member::MemberEventContent {
let event = 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(
body.room_id.clone(),