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
1 changed files with 34 additions and 33 deletions

View File

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