Add support for Media Envelope for uploads

This commit is contained in:
Leonora Tindall 2022-11-02 14:37:45 -05:00
parent 8ed1790cd2
commit c4c486dc8a
Signed by: nora
GPG Key ID: 7A8B52EC67E09AAF
6 changed files with 2433 additions and 117 deletions

116
Cargo.lock generated
View File

@ -547,22 +547,6 @@ dependencies = [
"version_check",
]
[[package]]
name = "cookie_store"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e4b6aa369f41f5faa04bb80c9b1f4216ea81646ed6124d76ba5c49a7aafd9cd"
dependencies = [
"cookie",
"idna 0.2.3",
"log",
"publicsuffix",
"serde",
"serde_json",
"time 0.3.16",
"url",
]
[[package]]
name = "core-foundation"
version = "0.9.3"
@ -587,8 +571,9 @@ dependencies = [
"cached",
"chrono",
"clap",
"eggbug",
"http-cache-reqwest",
"mime",
"mime_guess",
"once_cell",
"pulldown-cmark",
"reqwest",
@ -793,17 +778,6 @@ dependencies = [
"syn",
]
[[package]]
name = "derive_more"
version = "0.99.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "devise"
version = "0.3.1"
@ -875,29 +849,6 @@ dependencies = [
"chrono",
]
[[package]]
name = "eggbug"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4004d4ec28b9e2c564617596bebe2fe586d2c2baef0b34311c358ccf875530d4"
dependencies = [
"base64 0.13.1",
"bytes",
"derive_more",
"futures",
"hmac",
"pbkdf2",
"reqwest",
"serde",
"serde_json",
"sha2 0.10.6",
"thiserror",
"tokio",
"tokio-util",
"tracing",
"uuid",
]
[[package]]
name = "either"
version = "1.8.0"
@ -1392,17 +1343,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8"
dependencies = [
"matches",
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "idna"
version = "0.3.0"
@ -1543,12 +1483,6 @@ dependencies = [
"regex-automata",
]
[[package]]
name = "matches"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "memchr"
version = "2.5.0"
@ -1811,15 +1745,6 @@ dependencies = [
"windows-sys 0.42.0",
]
[[package]]
name = "pbkdf2"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917"
dependencies = [
"digest 0.10.5",
]
[[package]]
name = "pear"
version = "0.2.3"
@ -1923,12 +1848,6 @@ dependencies = [
"version_check",
]
[[package]]
name = "proc-macro-hack"
version = "0.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]]
name = "proc-macro2"
version = "1.0.47"
@ -1951,22 +1870,6 @@ dependencies = [
"yansi",
]
[[package]]
name = "psl-types"
version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac"
[[package]]
name = "publicsuffix"
version = "2.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96a8c1bda5ae1af7f99a2962e49df150414a43d62404644d98dd5c3a93d07457"
dependencies = [
"idna 0.3.0",
"psl-types",
]
[[package]]
name = "pulldown-cmark"
version = "0.9.2"
@ -2098,8 +2001,6 @@ checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc"
dependencies = [
"base64 0.13.1",
"bytes",
"cookie",
"cookie_store",
"encoding_rs",
"futures-core",
"futures-util",
@ -2117,13 +2018,11 @@ dependencies = [
"once_cell",
"percent-encoding",
"pin-project-lite",
"proc-macro-hack",
"serde",
"serde_json",
"serde_urlencoded",
"tokio",
"tokio-native-tls",
"tokio-util",
"tower-service",
"url",
"wasm-bindgen",
@ -2881,20 +2780,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643"
dependencies = [
"form_urlencoded",
"idna 0.3.0",
"idna",
"percent-encoding",
"serde",
]
[[package]]
name = "uuid"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83"
dependencies = [
"serde",
]
[[package]]
name = "valuable"
version = "0.1.0"

View File

@ -7,7 +7,6 @@ edition = "2021"
[dependencies]
clap = { version = "4.0.18", features = [ "derive" ] }
eggbug = { version = "0.1.2", features = [ "tokio" ] }
reqwest = "0.11.12"
rocket = { version = "0.5.0-rc.2", features = [ "json" ] }
serde = { version = "1.0.147", features = [ "derive" ] }
@ -21,3 +20,5 @@ atom_syndication = "0.11.0"
http-cache-reqwest = "0.5.0"
reqwest-middleware = "0.1.6"
cached = "0.40.0"
mime = "0.3.16"
mime_guess = "2.0.4"

View File

@ -25,5 +25,4 @@ ports to use for development and deployment.
- [x] Nicer theme
- [ ] Read More support
- [ ] Dublin Core support
- [ ] Media Envelope support
- [x] Media Envelope support

File diff suppressed because it is too large Load Diff

View File

@ -44,6 +44,15 @@ pub struct CohostPost {
default
)]
pub url: String,
#[serde(
deserialize_with = "deserialize_null_default",
default
)]
pub blocks: Vec<CohostPostBlock>,
#[serde(
rename = "transparentShareOfPostId",
)]
pub transparent_share_of_post_id: Option<u64>,
#[serde(rename = "postingProject")]
pub poster: CohostPostingProject,
#[serde(rename = "shareTree")]
@ -84,6 +93,18 @@ pub struct CohostPostLink {
pub t_type: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct CohostPostBlock {
pub attachment: Option<CohostPostAttachment>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct CohostPostAttachment {
#[serde(rename = "fileURL", deserialize_with = "deserialize_null_default", default)]
pub file_url: String,
}
fn deserialize_null_default<'de, D, T>(deserializer: D) -> Result<T, D::Error>
where
T: Default + Deserialize<'de>,

View File

@ -108,9 +108,15 @@ pub fn channel_for_posts_page(
let parser = pulldown_cmark::Parser::new_ext(&body_text, options);
let mut html_output = String::new();
pulldown_cmark::html::push_html(&mut html_output, parser);
item_builder.content(html_output);
for attachment in item.blocks.into_iter().filter_map(|block| block.attachment) {
use rss::EnclosureBuilder;
use mime_guess::from_path as guess_mime_from_path;
let enclosure = EnclosureBuilder::default().mime_type(guess_mime_from_path(&attachment.file_url).first_or_octet_stream().to_string()).url(attachment.file_url).build();
item_builder.enclosure(enclosure);
}
items.push(item_builder.build());
}