From: David ‘Bombe’ Roden Date: Fri, 31 Jul 2015 15:00:34 +0000 (+0200) Subject: Return replies to old post ID in compatibility mode X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2f722682a2ab877f614d024497e3559cc4bea579;p=Sone.git Return replies to old post ID in compatibility mode --- 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()); } /**