Rebase with master and update append_pdu call
parent
c8d7d80eb2
commit
7a70d8488f
|
@ -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,22 +573,24 @@ 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 {
|
||||||
if let Some(redact_id) = &redacts {
|
EventType::RoomRedaction => {
|
||||||
// TODO: Reason
|
if let Some(redact_id) = &redacts {
|
||||||
let _reason =
|
// TODO: Reason
|
||||||
serde_json::from_value::<Raw<redaction::RedactionEventContent>>(content)
|
let _reason =
|
||||||
.expect("Raw::from_value always works.")
|
serde_json::from_value::<Raw<redaction::RedactionEventContent>>(content)
|
||||||
.deserialize()
|
.expect("Raw::from_value always works.")
|
||||||
.map_err(|_| {
|
.deserialize()
|
||||||
Error::BadRequest(
|
.map_err(|_| {
|
||||||
ErrorKind::InvalidParam,
|
Error::BadRequest(
|
||||||
"Invalid redaction event content.",
|
ErrorKind::InvalidParam,
|
||||||
)
|
"Invalid redaction event content.",
|
||||||
})?
|
)
|
||||||
.reason;
|
})?
|
||||||
|
.reason;
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -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,
|
},
|
||||||
account_data,
|
globals,
|
||||||
)
|
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, &[])?;
|
||||||
|
|
Loading…
Reference in New Issue