Browse Source
Fix sends expecting size to be a string on mobile
pull/4386/head
Daniel García
10 months ago
No known key found for this signature in database
GPG Key ID: FC8A7D14C3CD543A
1 changed files with
12 additions and
2 deletions
-
src/db/models/send.rs
|
|
@ -124,7 +124,12 @@ impl Send { |
|
|
|
use data_encoding::BASE64URL_NOPAD; |
|
|
|
use uuid::Uuid; |
|
|
|
|
|
|
|
let data = serde_json::from_str::<LowerCase<Value>>(&self.data).map(|d| d.data).unwrap_or_default(); |
|
|
|
let mut data = serde_json::from_str::<LowerCase<Value>>(&self.data).map(|d| d.data).unwrap_or_default(); |
|
|
|
|
|
|
|
// Mobile clients expect size to be a string instead of a number
|
|
|
|
if let Some(size) = data.get("size").and_then(|v| v.as_i64()) { |
|
|
|
data["size"] = Value::String(size.to_string()); |
|
|
|
} |
|
|
|
|
|
|
|
json!({ |
|
|
|
"id": self.uuid, |
|
|
@ -153,7 +158,12 @@ impl Send { |
|
|
|
pub async fn to_json_access(&self, conn: &mut DbConn) -> Value { |
|
|
|
use crate::util::format_date; |
|
|
|
|
|
|
|
let data = serde_json::from_str::<LowerCase<Value>>(&self.data).map(|d| d.data).unwrap_or_default(); |
|
|
|
let mut data = serde_json::from_str::<LowerCase<Value>>(&self.data).map(|d| d.data).unwrap_or_default(); |
|
|
|
|
|
|
|
// Mobile clients expect size to be a string instead of a number
|
|
|
|
if let Some(size) = data.get("size").and_then(|v| v.as_i64()) { |
|
|
|
data["size"] = Value::String(size.to_string()); |
|
|
|
} |
|
|
|
|
|
|
|
json!({ |
|
|
|
"id": self.uuid, |
|
|
|