From: David ‘Bombe’ Roden Date: Sat, 23 Oct 2010 11:24:14 +0000 (+0200) Subject: Store and parse replies in/from inserted Sone. X-Git-Tag: 0.1-RC1~62 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=bf6da11210fb439f2cdc8fcb8755589d04b4db3b;p=Sone.git Store and parse replies in/from inserted Sone. --- diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java index 4923736..ac39291 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java @@ -290,6 +290,20 @@ public class SoneDownloader extends AbstractService { likedPostIds.add(postId); } + /* parse liked reply IDs. */ + SimpleXML likeReplyIdsXml = soneXml.getNode("reply-likes"); + if (likeReplyIdsXml == null) { + /* TODO - mark Sone as bad. */ + logger.log(Level.WARNING, "Downloaded Sone %s has no reply likes!", new Object[] { sone }); + return null; + } + + Set likedReplyIds = new HashSet(); + for (SimpleXML likedReplyIdXml : likeReplyIdsXml.getNodes("reply-like")) { + String replyId = likedReplyIdXml.getValue(); + likedReplyIds.add(replyId); + } + /* parse known Sones. */ SimpleXML knownSonesXml = soneXml.getNode("known-sones"); if (knownSonesXml == null) { diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index 8c67a91..136c1e3 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -183,6 +183,7 @@ public class SoneInserter extends AbstractService { soneProperties.put("replies", new HashSet(sone.getReplies())); soneProperties.put("blockedSoneIds", new HashSet(sone.getBlockedSoneIds())); soneProperties.put("likedPostIds", new HashSet(sone.getLikedPostIds())); + soneProperties.put("likeReplyIds", new HashSet(sone.getLikedReplyIds())); } // diff --git a/src/main/resources/templates/insert/sone.xml b/src/main/resources/templates/insert/sone.xml index 66032d5..229ac42 100644 --- a/src/main/resources/templates/insert/sone.xml +++ b/src/main/resources/templates/insert/sone.xml @@ -38,6 +38,12 @@ <%/foreach> + + <%foreach currentSone.likedReplyIds replyId> + <% replyId|xml> + <%/foreach> + + <%foreach knownSones sone>