A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(unfurl): tidy ActivityPub preview checks (#3779)
Hampus5f3fc0b1c669
diff --git a/fluxer_unfurl/src/activity_pub/mod.rs b/fluxer_unfurl/src/activity_pub/mod.rsindex 97aa65fb6..06925ec0a 100644--- a/fluxer_unfurl/src/activity_pub/mod.rs+++ b/fluxer_unfurl/src/activity_pub/mod.rs@@ -79,7 +79,11 @@ async fn resolve_activity_pub_post() -> Option<Vec<MessageEmbed>> {let post = fetcher::fetch_activity_pub(client, ap_url).await?;let author_actor = fetch_post_author_actor(client, &post).await;- if visibility::is_hidden_from_unauthed_web(&post, author_actor.as_ref()) {+ if visibility::is_hidden_from_unauthed_web(+ &post,+ author_actor.as_ref(),+ client.signer.is_some(),+ ) {return None;}let mut context = build_context(client, url, Some(html)).await;@@ -150,7 +154,11 @@ async fn fetch_activity_pub_reply_context() -> Option<types::ActivityPubReplyContext> {let parent = fetcher::fetch_activity_pub(client, parent_url).await?;let author_actor = fetch_post_author_actor(client, &parent).await;- if visibility::is_hidden_from_unauthed_web(&parent, author_actor.as_ref()) {+ if visibility::is_hidden_from_unauthed_web(+ &parent,+ author_actor.as_ref(),+ client.signer.is_some(),+ ) {return None;}let author = match author_actor.as_ref() {@@ -199,7 +207,11 @@ async fn fetch_activity_pub_quote_child(.or(post.misskey_quote.as_deref())?;let quote = fetcher::fetch_activity_pub(client, quote_url).await?;let author_actor = fetch_post_author_actor(client, "e).await;- if visibility::is_hidden_from_unauthed_web("e, author_actor.as_ref()) {+ if visibility::is_hidden_from_unauthed_web(+ "e,+ author_actor.as_ref(),+ client.signer.is_some(),+ ) {return None;}let fallback = Url::parse(quote_url).ok()?;diff --git a/fluxer_unfurl/src/activity_pub/visibility.rs b/fluxer_unfurl/src/activity_pub/visibility.rsindex 3ff1ce11e..128007e18 100644--- a/fluxer_unfurl/src/activity_pub/visibility.rs+++ b/fluxer_unfurl/src/activity_pub/visibility.rs@@ -18,9 +18,10 @@ enum WebVisibility {pub fn is_hidden_from_unauthed_web(post: &ActivityPubPost,author: Option<&ActivityPubActor>,+ signed: bool,) -> bool {let Some(author) = author else {- return false;+ return signed;};if author.hides_to_public_from_unauthed_web.is_none()&& author.hides_cc_public_from_unauthed_web.is_none()diff --git a/fluxer_unfurl/src/resolvers/default_resolver.rs b/fluxer_unfurl/src/resolvers/default_resolver.rsindex e73da81b0..21b87aa1b 100644--- a/fluxer_unfurl/src/resolvers/default_resolver.rs+++ b/fluxer_unfurl/src/resolvers/default_resolver.rs@@ -505,6 +505,13 @@ async fn try_canonical_activity_pub(.unwrap_or_else(|| canonical_url.clone());let context = activity_pub::build_context(client, &post_url, None).await;let author_actor = activity_pub::fetch_post_author_actor(client, &ap_post).await;+ if activity_pub::visibility::is_hidden_from_unauthed_web(+ &ap_post,+ author_actor.as_ref(),+ client.signer.is_some(),+ ) {+ return None;+ }let embeds = activity_pub::formatter::format_activity_pub_post(&ap_post,&post_url,