From: David ‘Bombe’ Roden Date: Fri, 26 Nov 2010 19:16:45 +0000 (+0100) Subject: Add methods to create a post with a recipient. X-Git-Tag: 0.3.2-RC1~15^2~7 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=f5498bd2898e551e4424efb6cc6463306b62e974 Add methods to create a post with a recipient. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index e1dcb9c..bdea989 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1216,11 +1216,48 @@ public class Core implements IdentityListener { * @return The created post */ public Post createPost(Sone sone, long time, String text) { + return createPost(sone, null, time, text); + } + + /** + * Creates a new post. + * + * @param sone + * The Sone that creates the post + * @param recipient + * The recipient Sone, or {@code null} if this post does not have + * a recipient + * @param text + * The text of the post + * @return The created post + */ + public Post createPost(Sone sone, Sone recipient, String text) { + return createPost(sone, recipient, System.currentTimeMillis(), text); + } + + /** + * Creates a new post. + * + * @param sone + * The Sone that creates the post + * @param recipient + * The recipient Sone, or {@code null} if this post does not have + * a recipient + * @param time + * The time of the post + * @param text + * The text of the post + * @return The created post + */ + public Post createPost(Sone sone, Sone recipient, long time, String text) { if (!isLocalSone(sone)) { logger.log(Level.FINE, "Tried to create post for non-local Sone: %s", sone); return null; } Post post = new Post(sone, time, text); + if (recipient != null) { + post.setRecipient(recipient); + } synchronized (posts) { posts.put(post.getId(), post); }