*
* 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
*
* 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
import net.pterodactylus.util.io.Closer;
import net.pterodactylus.util.json.JsonObject;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.io.Closer;
import net.pterodactylus.util.json.JsonObject;
import net.pterodactylus.util.template.Template;
- Reply reply = webInterface.getCore().getReply(replyId);
- if ((reply == null) || (reply.getSone() == null)) {
+ Optional<PostReply> reply = webInterface.getCore().getPostReply(replyId);
+ if (!reply.isPresent()) {
- return createSuccessJsonObject().put("reply", createJsonReply(reply, getCurrentSone(request.getToadletContext())));
+ return createSuccessJsonObject().put("reply", createJsonReply(request, reply.get(), getCurrentSone(request.getToadletContext())));
* @param reply
* The reply to convert
* @param currentSone
* The currently logged in Sone (to store in the template)
* @return The JSON representation of the reply
*/
* @param reply
* The reply to convert
* @param currentSone
* The currently logged in Sone (to store in the template)
* @return The JSON representation of the reply
*/
JsonObject jsonReply = new JsonObject();
jsonReply.put("id", reply.getId());
jsonReply.put("postId", reply.getPost().getId());
JsonObject jsonReply = new JsonObject();
jsonReply.put("id", reply.getId());
jsonReply.put("postId", reply.getPost().getId());
jsonReply.put("time", reply.getTime());
StringWriter stringWriter = new StringWriter();
TemplateContext templateContext = webInterface.getTemplateContextFactory().createTemplateContext();
jsonReply.put("time", reply.getTime());
StringWriter stringWriter = new StringWriter();
TemplateContext templateContext = webInterface.getTemplateContextFactory().createTemplateContext();
templateContext.set("reply", reply);
templateContext.set("currentSone", currentSone);
try {
templateContext.set("reply", reply);
templateContext.set("currentSone", currentSone);
try {