feat: media
This commit is contained in:
parent
42ae433b25
commit
821c608c6a
5 changed files with 132 additions and 13 deletions
|
@ -11,7 +11,7 @@ use ruma_identifiers::UserId;
|
|||
use std::{convert::TryInto, io::Cursor, ops::Deref};
|
||||
use tokio::io::AsyncReadExt;
|
||||
|
||||
const MESSAGE_LIMIT: u64 = 65535;
|
||||
const MESSAGE_LIMIT: u64 = 20 * 1024 * 1024; // 20 MB
|
||||
|
||||
/// This struct converts rocket requests into ruma structs by converting them into http requests
|
||||
/// first.
|
||||
|
@ -19,7 +19,7 @@ pub struct Ruma<T> {
|
|||
body: T,
|
||||
pub user_id: Option<UserId>,
|
||||
pub device_id: Option<String>,
|
||||
pub json_body: serde_json::Value,
|
||||
pub json_body: Option<serde_json::Value>, // This is None if parsing failed (for raw byte bodies)
|
||||
}
|
||||
|
||||
impl<'a, T: Endpoint> FromData<'a> for Ruma<T> {
|
||||
|
@ -85,12 +85,8 @@ impl<'a, T: Endpoint> FromData<'a> for Ruma<T> {
|
|||
body: t,
|
||||
user_id,
|
||||
device_id,
|
||||
// TODO: Can we avoid parsing it again?
|
||||
json_body: if !body.is_empty() {
|
||||
serde_json::from_slice(&body).expect("Ruma already parsed it successfully")
|
||||
} else {
|
||||
serde_json::Value::default()
|
||||
},
|
||||
// TODO: Can we avoid parsing it again? (We only need this for append_pdu)
|
||||
json_body: serde_json::from_slice(&body).ok()
|
||||
}),
|
||||
Err(e) => {
|
||||
warn!("{:?}", e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue