import java.util.Set;
import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Reply;
+import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.template.SoneAccessor;
import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.json.JsonArray;
import net.pterodactylus.util.json.JsonObject;
* The Sone web interface
*/
public GetLikesAjaxPage(WebInterface webInterface) {
- super("ajax/getLikes.ajax", webInterface);
+ super("getLikes.ajax", webInterface);
}
//
* {@inheritDoc}
*/
@Override
- protected JsonObject createJsonObject(Request request) {
+ protected JsonObject createJsonObject(FreenetRequest request) {
String type = request.getHttpRequest().getParam("type", null);
String id = request.getHttpRequest().getParam(type, null);
if ((id == null) || (id.length() == 0)) {
if ("post".equals(type)) {
Post post = webInterface.getCore().getPost(id);
Set<Sone> sones = webInterface.getCore().getLikes(post);
- return new JsonObject().put("success", true).put("likes", sones.size()).put("sones", getSones(sones));
+ return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones));
} else if ("reply".equals(type)) {
- Reply reply = webInterface.getCore().getReply(id);
+ PostReply reply = webInterface.getCore().getReply(id);
Set<Sone> sones = webInterface.getCore().getLikes(reply);
- return new JsonObject().put("success", true).put("likes", sones.size()).put("sones", getSones(sones));
+ return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones));
}
return createErrorJsonObject("invalid-type");
}