X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FCreatePostCommand.java;h=01b52aac9f354178336af7a8316fc469b8aa19f2;hb=8d49fb185ee26853262a12f6d419ef2e39c1116c;hp=a37dc46bbe82de76daa8a999bbf8c228a04648de;hpb=a47643aed43d118ca68044f95451bb5374cdb332;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java b/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java index a37dc46..01b52aa 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–2012 David Roden + * Sone - CreatePostCommand.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 @@ -17,18 +17,22 @@ package net.pterodactylus.sone.fcp; +import static com.google.common.base.Optional.fromNullable; +import static com.google.common.base.Optional.of; +import static net.pterodactylus.sone.data.Identified.GET_ID; + 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 */ public class CreatePostCommand extends AbstractSoneCommand { @@ -57,7 +61,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 = sone.newPostBuilder().to(fromNullable(recipient).transform(GET_ID)).withText(text).build(of(getCore().postCreated())); return new Response("PostCreated", new SimpleFieldSetBuilder().put("Post", post.getId()).get()); }