feat: implement server ACLs
This commit is contained in:
parent
d434dfb3a5
commit
ee8e72f7a8
10 changed files with 150 additions and 58 deletions
|
@ -23,7 +23,7 @@ use ruma::{
|
|||
},
|
||||
EventType,
|
||||
},
|
||||
serde::{to_canonical_value, CanonicalJsonObject, CanonicalJsonValue},
|
||||
serde::{to_canonical_value, Base64, CanonicalJsonObject, CanonicalJsonValue},
|
||||
state_res::{self, RoomVersion},
|
||||
uint, EventId, RoomId, RoomVersionId, ServerName, UserId,
|
||||
};
|
||||
|
@ -787,7 +787,7 @@ async fn join_room_by_id_helper(
|
|||
fn validate_and_add_event_id(
|
||||
pdu: &RawJsonValue,
|
||||
room_version: &RoomVersionId,
|
||||
pub_key_map: &RwLock<BTreeMap<String, BTreeMap<String, String>>>,
|
||||
pub_key_map: &RwLock<BTreeMap<String, BTreeMap<String, Base64>>>,
|
||||
db: &Database,
|
||||
) -> Result<(Box<EventId>, CanonicalJsonObject)> {
|
||||
let mut value: CanonicalJsonObject = serde_json::from_str(pdu.get()).map_err(|e| {
|
||||
|
|
|
@ -74,11 +74,11 @@ pub async fn send_message_event_route(
|
|||
}
|
||||
|
||||
let mut unsigned = BTreeMap::new();
|
||||
unsigned.insert("transaction_id".to_owned(), body.txn_id.clone().into());
|
||||
unsigned.insert("transaction_id".to_owned(), body.txn_id.to_string().into());
|
||||
|
||||
let event_id = db.rooms.build_and_append_pdu(
|
||||
PduBuilder {
|
||||
event_type: EventType::from(&body.event_type),
|
||||
event_type: EventType::from(&*body.event_type),
|
||||
content: serde_json::from_str(body.body.body.json().get())
|
||||
.map_err(|_| Error::BadRequest(ErrorKind::BadJson, "Invalid JSON body."))?,
|
||||
unsigned: Some(unsigned),
|
||||
|
|
|
@ -44,7 +44,7 @@ pub async fn send_state_event_for_key_route(
|
|||
&db,
|
||||
sender_user,
|
||||
&body.room_id,
|
||||
EventType::from(&body.event_type),
|
||||
EventType::from(&*body.event_type),
|
||||
&body.body.body, // Yes, I hate it too
|
||||
body.state_key.to_owned(),
|
||||
)
|
||||
|
@ -86,7 +86,7 @@ pub async fn send_state_event_for_empty_key_route(
|
|||
&db,
|
||||
sender_user,
|
||||
&body.room_id,
|
||||
EventType::from(&body.event_type),
|
||||
EventType::from(&*body.event_type),
|
||||
&body.body.body,
|
||||
body.state_key.to_owned(),
|
||||
)
|
||||
|
|
|
@ -53,8 +53,8 @@ pub async fn send_event_to_device_route(
|
|||
serde_json::to_vec(&federation::transactions::edu::Edu::DirectToDevice(
|
||||
DirectDeviceContent {
|
||||
sender: sender_user.clone(),
|
||||
ev_type: EventType::from(&body.event_type),
|
||||
message_id: body.txn_id.clone(),
|
||||
ev_type: EventType::from(&*body.event_type),
|
||||
message_id: body.txn_id.to_string(),
|
||||
messages,
|
||||
},
|
||||
))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue