From 1671de49cbc8add26cc115838a218039b2e8cb34 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Sun, 13 Aug 2023 13:37:43 +0900 Subject: [PATCH] Adjust card entity --- examples/mastodon_streaming.rs | 2 +- src/entities/card.rs | 6 ++++-- src/friendica/entities/card.rs | 27 +++++++++++++++------------ src/mastodon/entities/card.rs | 28 ++++++++++++++++------------ src/pleroma/entities/card.rs | 21 +++++++++------------ 5 files changed, 45 insertions(+), 39 deletions(-) diff --git a/examples/mastodon_streaming.rs b/examples/mastodon_streaming.rs index e36b6f4..bdca3a0 100644 --- a/examples/mastodon_streaming.rs +++ b/examples/mastodon_streaming.rs @@ -24,7 +24,7 @@ async fn streaming(url: &str, access_token: String) { Some(access_token), None, ); - let streaming = client.user_streaming(url.to_string()); + let streaming = client.local_streaming(url.to_string()); streaming .listen(Box::new(|message| match message { diff --git a/src/entities/card.rs b/src/entities/card.rs index 07283c3..85e34c7 100644 --- a/src/entities/card.rs +++ b/src/entities/card.rs @@ -9,11 +9,13 @@ pub struct Card { pub image: Option, pub author_name: Option, pub author_url: Option, - pub provider_name: Option, - pub provider_url: Option, + pub provider_name: String, + pub provider_url: String, pub html: Option, pub width: Option, pub height: Option, + pub embed_url: Option, + pub blurhash: Option, } #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/src/friendica/entities/card.rs b/src/friendica/entities/card.rs index c760de7..2d72883 100644 --- a/src/friendica/entities/card.rs +++ b/src/friendica/entities/card.rs @@ -8,13 +8,14 @@ pub struct Card { description: String, r#type: CardType, image: Option, - author_name: Option, - author_url: Option, - provider_name: Option, - provider_url: Option, - html: Option, - width: Option, - height: Option, + author_name: String, + author_url: String, + provider_name: String, + provider_url: String, + html: String, + width: u32, + height: u32, + blurhash: Option, } #[derive(Debug, Clone, Deserialize, Serialize)] @@ -45,13 +46,15 @@ impl Into for Card { description: self.description, r#type: self.r#type.into(), image: self.image, - author_name: self.author_name, - author_url: self.author_url, + author_name: Some(self.author_name), + author_url: Some(self.author_url), provider_name: self.provider_name, provider_url: self.provider_url, - html: self.html, - width: self.width, - height: self.height, + html: Some(self.html), + width: Some(self.width), + height: Some(self.height), + embed_url: None, + blurhash: self.blurhash, } } } diff --git a/src/mastodon/entities/card.rs b/src/mastodon/entities/card.rs index c760de7..c09f817 100644 --- a/src/mastodon/entities/card.rs +++ b/src/mastodon/entities/card.rs @@ -8,13 +8,15 @@ pub struct Card { description: String, r#type: CardType, image: Option, - author_name: Option, - author_url: Option, - provider_name: Option, - provider_url: Option, - html: Option, - width: Option, - height: Option, + author_name: String, + author_url: String, + provider_name: String, + provider_url: String, + html: String, + width: u32, + height: u32, + embed_url: String, + blurhash: Option, } #[derive(Debug, Clone, Deserialize, Serialize)] @@ -45,13 +47,15 @@ impl Into for Card { description: self.description, r#type: self.r#type.into(), image: self.image, - author_name: self.author_name, - author_url: self.author_url, + author_name: Some(self.author_name), + author_url: Some(self.author_url), provider_name: self.provider_name, provider_url: self.provider_url, - html: self.html, - width: self.width, - height: self.height, + html: Some(self.html), + width: Some(self.width), + height: Some(self.height), + embed_url: Some(self.embed_url), + blurhash: self.blurhash, } } } diff --git a/src/pleroma/entities/card.rs b/src/pleroma/entities/card.rs index c760de7..16c74d8 100644 --- a/src/pleroma/entities/card.rs +++ b/src/pleroma/entities/card.rs @@ -8,13 +8,8 @@ pub struct Card { description: String, r#type: CardType, image: Option, - author_name: Option, - author_url: Option, - provider_name: Option, - provider_url: Option, - html: Option, - width: Option, - height: Option, + provider_name: String, + provider_url: String, } #[derive(Debug, Clone, Deserialize, Serialize)] @@ -45,13 +40,15 @@ impl Into for Card { description: self.description, r#type: self.r#type.into(), image: self.image, - author_name: self.author_name, - author_url: self.author_url, + author_name: None, + author_url: None, provider_name: self.provider_name, provider_url: self.provider_url, - html: self.html, - width: self.width, - height: self.height, + html: None, + width: None, + height: None, + embed_url: None, + blurhash: None, } } }