X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FCreatePostCommand.java;h=590b8f491fd9f1cdde1df0d224e88a9fd2f5ac2b;hp=db2189e2581ea656f525587c677defb112b192ea;hb=62573c314957b1851f4fbe693b8746686caa940a;hpb=317730570a54d7f95a22a59320ea503b9cad2571 diff --git a/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java b/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java index db2189e..590b8f4 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java @@ -1,5 +1,5 @@ /* - * Sone - CreatePostCommand.java - Copyright © 2011 David Roden + * Sone - CreatePostCommand.java - Copyright © 2011–2016 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 @@ -17,19 +17,19 @@ package net.pterodactylus.sone.fcp; +import com.google.common.base.Optional; + import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.freenet.SimpleFieldSetBuilder; import net.pterodactylus.sone.freenet.fcp.FcpException; import freenet.support.SimpleFieldSet; -import freenet.support.api.Bucket; /** * FCP command that creates a new {@link Post}. * - * @see Core#createPost(Sone, Sone, String) - * @author David ‘Bombe’ Roden + * @see Core#createPost(Sone, Optional, String) */ public class CreatePostCommand extends AbstractSoneCommand { @@ -40,14 +40,14 @@ public class CreatePostCommand extends AbstractSoneCommand { * The Sone core */ public CreatePostCommand(Core core) { - super(core); + super(core, true); } /** * {@inheritDoc} */ @Override - public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException { + public Response execute(SimpleFieldSet parameters) throws FcpException { Sone sone = getSone(parameters, "Sone", true); String text = getString(parameters, "Text"); Sone recipient = null; @@ -57,7 +57,7 @@ public class CreatePostCommand extends AbstractSoneCommand { if (sone.equals(recipient)) { return new ErrorResponse("Sone and Recipient must not be the same."); } - Post post = getCore().createPost(sone, recipient, text); + Post post = getCore().createPost(sone, Optional.fromNullable(recipient), text); return new Response("PostCreated", new SimpleFieldSetBuilder().put("Post", post.getId()).get()); }