Store the insert URI in the information used for inserting.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneInserter.java
index 36eb300..8e253ee 100644 (file)
@@ -19,6 +19,8 @@ package net.pterodactylus.sone.core;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static net.pterodactylus.sone.data.Album.NOT_EMPTY;
+import static net.pterodactylus.sone.data.Sone.TO_FREENET_URI;
+import static net.pterodactylus.sone.data.Sone.TO_INSERT_URI;
 
 import java.io.InputStreamReader;
 import java.io.StringWriter;
@@ -244,7 +246,7 @@ public class SoneInserter extends AbstractService {
                                                        break;
                                                }
                                                sone.setTime(insertTime);
-                                               sone.setLatestEdition(finalUri.getEdition());
+                                               sone.modify().setLatestEdition(finalUri.getEdition()).update();
                                                core.touchConfiguration();
                                                success = true;
                                                logger.log(Level.INFO, String.format("Inserted Sone ā€œ%sā€ at %s.", sone.getName(), finalUri));
@@ -299,7 +301,8 @@ public class SoneInserter extends AbstractService {
                        soneProperties.put("id", sone.getId());
                        soneProperties.put("name", sone.getName());
                        soneProperties.put("time", sone.getTime());
-                       soneProperties.put("requestUri", sone.getRequestUri());
+                       soneProperties.put("requestUri", TO_FREENET_URI.apply(sone));
+                       soneProperties.put("insertUri", TO_INSERT_URI.apply(sone));
                        soneProperties.put("profile", sone.getProfile());
                        soneProperties.put("posts", Ordering.from(Post.TIME_COMPARATOR).sortedCopy(sone.getPosts()));
                        soneProperties.put("replies", Ordering.from(Reply.TIME_COMPARATOR).reverse().sortedCopy(sone.getReplies()));