Rebase with master and update append_pdu call

This commit is contained in:
Devin Ragotzy 2020-07-30 08:43:51 -04:00
parent c8d7d80eb2
commit 7a70d8488f

View file

@ -388,7 +388,7 @@ impl Rooms {
.join_rule) .join_rule)
})?; })?;
let authorized = if target_membership == member::MembershipState::Join { if target_membership == member::MembershipState::Join {
let mut prev_events = prev_events.iter(); let mut prev_events = prev_events.iter();
let prev_event = self let prev_event = self
.get_pdu(prev_events.next().ok_or(Error::BadRequest( .get_pdu(prev_events.next().ok_or(Error::BadRequest(
@ -461,14 +461,11 @@ impl Rooms {
} }
} else { } else {
false false
}; }
authorized
} }
EventType::RoomCreate => prev_events.is_empty(), EventType::RoomCreate => prev_events.is_empty(),
// Not allow any of the following events if the sender is not joined. // Not allow any of the following events if the sender is not joined.
_ if sender_membership != member::MembershipState::Join => false, _ if sender_membership != member::MembershipState::Join => false,
_ => { _ => {
// TODO // TODO
sender_power.unwrap_or(&power_levels.users_default) sender_power.unwrap_or(&power_levels.users_default)
@ -576,7 +573,8 @@ impl Rooms {
self.roomstateid_pdu.insert(key, &*pdu_json.to_string())?; self.roomstateid_pdu.insert(key, &*pdu_json.to_string())?;
} }
if let EventType::RoomRedaction = event_type { match event_type {
EventType::RoomRedaction => {
if let Some(redact_id) = &redacts { if let Some(redact_id) = &redacts {
// TODO: Reason // TODO: Reason
let _reason = let _reason =
@ -593,6 +591,7 @@ impl Rooms {
self.redact_pdu(&redact_id)?; self.redact_pdu(&redact_id)?;
} }
}
EventType::RoomMember => { EventType::RoomMember => {
if let Some(state_key) = state_key { if let Some(state_key) = state_key {
// if the state_key fails // if the state_key fails
@ -800,20 +799,22 @@ impl Rooms {
if is_ignored { if is_ignored {
member_content.membership = member::MembershipState::Leave; member_content.membership = member::MembershipState::Leave;
return self self.append_pdu(
.append_pdu( PduBuilder {
room_id.clone(), room_id: room_id.clone(),
user_id.clone(), sender: user_id.clone(),
EventType::RoomMember, event_type: EventType::RoomMember,
serde_json::to_value(member_content) content: serde_json::to_value(member_content)
.expect("event is valid, we just created it"), .expect("event is valid, we just created it"),
None, unsigned: None,
Some(user_id.to_string()), state_key: Some(user_id.to_string()),
None, redacts: None,
},
globals, globals,
account_data, account_data,
) )?;
.map(|_| ());
return Ok(());
} }
self.userroomid_invited.insert(&userroom_id, &[])?; self.userroomid_invited.insert(&userroom_id, &[])?;
self.roomuserid_invited.insert(&roomuser_id, &[])?; self.roomuserid_invited.insert(&roomuser_id, &[])?;