From: Dessalines Date: Wed, 21 Jun 2023 08:56:44 +0000 (-0400) Subject: Fixing cross_post duplicates. Fixes #3233 (#3234) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/nerdica.net/static/sneer-club-logo.svg?a=commitdiff_plain;h=1ef095dd964842da0d0d159204b16f0e7bebb206;p=lemmy.git Fixing cross_post duplicates. Fixes #3233 (#3234) --- diff --git a/crates/api_crud/src/post/read.rs b/crates/api_crud/src/post/read.rs index 85106afe..d1851f33 100644 --- a/crates/api_crud/src/post/read.rs +++ b/crates/api_crud/src/post/read.rs @@ -91,12 +91,16 @@ impl PerformCrud for GetPost { // Fetch the cross_posts let cross_posts = if let Some(url) = &post_view.post.url { - PostQuery::builder() + let mut x_posts = PostQuery::builder() .pool(context.pool()) .url_search(Some(url.inner().as_str().into())) .build() .list() - .await? + .await?; + + // Don't return this post as one of the cross_posts + x_posts.retain(|x| x.post.id != post_id); + x_posts } else { Vec::new() };