Store the insert URI in the information used for inserting.
[Sone.git] / src / main / java / net / pterodactylus / sone / fcp / CreateReplyCommand.java
index 90af42c..4a53238 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - CreateReplyCommand.java - Copyright © 2011 David Roden
+ * Sone - CreateReplyCommand.java - Copyright © 2011–2013 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.fcp;
 
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Post;
+import net.pterodactylus.sone.data.PostReply;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.SimpleFieldSetBuilder;
@@ -41,18 +42,15 @@ public class CreateReplyCommand extends AbstractSoneCommand {
         *            The Sone core
         */
        public CreateReplyCommand(Core core) {
-               super(core);
+               super(core, true);
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
-               Sone sone = getSone(parameters, "Sone", true);
+               Sone sone = getMandatoryLocalSone(parameters, "Sone");
                Post post = getPost(parameters, "Post");
                String text = getString(parameters, "Text");
-               Reply reply = getCore().createReply(sone, post, text);
+               PostReply reply = sone.newPostReplyBuilder(post.getId()).withText(text).build(getCore().postReplyCreated());
                return new Response("ReplyCreated", new SimpleFieldSetBuilder().put("Reply", reply.getId()).get());
        }