X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FFollowSoneAjaxPage.java;h=d82ab1ded064061c54a0cd25d01b3ea5bc628c7a;hp=7dc1b247d5a3e9629fb0fda99abcc65cba0c62cf;hb=89a905395984ec35e313b07594e21773ffd3d9d8;hpb=01d2e31e5687276b5104edc27c3416d4cd9b89b8 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java index 7dc1b24..d82ab1d 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java @@ -35,7 +35,7 @@ public class FollowSoneAjaxPage extends JsonPage { * The Sone web interface */ public FollowSoneAjaxPage(WebInterface webInterface) { - super("ajax/followSone.ajax", webInterface); + super("followSone.ajax", webInterface); } /** @@ -44,17 +44,16 @@ public class FollowSoneAjaxPage extends JsonPage { @Override protected JsonObject createJsonObject(Request request) { String soneId = request.getHttpRequest().getParam("sone"); - Sone sone = webInterface.core().getSone(soneId); - if (sone == null) { - return new JsonObject().put("success", false).put("error", "invalid-sone-id"); + if (!webInterface.getCore().hasSone(soneId)) { + return createErrorJsonObject("invalid-sone-id"); } Sone currentSone = getCurrentSone(request.getToadletContext()); if (currentSone == null) { - return new JsonObject().put("success", false).put("error", "auth-required"); + return createErrorJsonObject("auth-required"); } - currentSone.addFriend(sone); - webInterface.core().saveSone(currentSone); - return new JsonObject().put("success", true); + currentSone.addFriend(soneId); + webInterface.getCore().touchConfiguration(); + return createSuccessJsonObject(); } }