From 2f722682a2ab877f614d024497e3559cc4bea579 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 31 Jul 2015 17:00:34 +0200 Subject: [PATCH] Return replies to old post ID in compatibility mode --- src/main/java/net/pterodactylus/sone/core/Core.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 140d80c..e56eede 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -103,8 +103,11 @@ import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; +import com.google.common.collect.Ordering; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import com.google.inject.Inject; @@ -489,7 +492,14 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, */ @Override public List getReplies(final String postId) { - return database.getReplies(postId); + Builder postReplies = ImmutableList.builder().addAll(database.getReplies(postId)); + if (isCompatibilityMode(CompatibilityMode.oldElementIds)) { + Optional post = getPost(postId); + if (post.isPresent()) { + postReplies.addAll(database.getReplies(post.get().getInternalId())); + } + } + return Ordering.from(Reply.TIME_COMPARATOR).sortedCopy(postReplies.build()); } /** -- 2.7.4