1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-11-19 04:00:49 +01:00

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.
This commit is contained in:
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

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
.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 {
membership: member::MembershipState::Join, membership: member::MembershipState::Join,
displayname: db.users.displayname(&user_id)?, displayname: db.users.displayname(&user_id)?,
avatar_url: db.users.avatar_url(&user_id)?, avatar_url: db.users.avatar_url(&user_id)?,
is_direct: None, is_direct: None,
third_party_invite: 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(),