]> Untitled Git - lemmy.git/commitdiff
Fixing cross_post duplicates. Fixes #3233 (#3234)
authorDessalines <dessalines@users.noreply.github.com>
Wed, 21 Jun 2023 08:56:44 +0000 (04:56 -0400)
committerGitHub <noreply@github.com>
Wed, 21 Jun 2023 08:56:44 +0000 (10:56 +0200)
crates/api_crud/src/post/read.rs

index 85106afe4a42d3cb04f3ddcf3b626b632646a957..d1851f33e39f4357577273170299bd70479cdde3 100644 (file)
@@ -91,12 +91,16 @@ impl PerformCrud for GetPost {
 
     // Fetch the cross_posts
     let cross_posts = if let Some(url) = &post_view.post.url {
 
     // 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()
         .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()
     };
     } else {
       Vec::new()
     };