Phoronix: fix first comment is article copy
authorNiki Roo <niki@nikiroo.be>
Wed, 26 Sep 2018 18:36:43 +0000 (20:36 +0200)
committerNiki Roo <niki@nikiroo.be>
Wed, 26 Sep 2018 18:36:43 +0000 (20:36 +0200)
src/be/nikiroo/gofetch/support/Phoronix.java

index 74096ad67afcd28fd478e62fe4a6e1edc132e596..c73ddc761594f69c23bba0dcf269091fe9ebe63a 100644 (file)
@@ -14,6 +14,9 @@ import org.jsoup.nodes.Element;
 import org.jsoup.nodes.Node;
 import org.jsoup.nodes.TextNode;
 
+import be.nikiroo.gofetch.data.Comment;
+import be.nikiroo.gofetch.data.Story;
+
 class Phoronix extends BasicSupport {
        @Override
        public String getDescription() {
@@ -236,4 +239,15 @@ class Phoronix extends BasicSupport {
                };
        }
 
+       @Override
+       public void fetch(Story story) throws IOException {
+               super.fetch(story);
+
+               // First comment is a copy of the article, discard it
+               List<Comment> comments = story.getComments();
+               if (comments != null && comments.size() > 1) {
+                       comments = comments.subList(1, comments.size());
+               }
+               story.setComments(comments);
+       }
 }