Add a core thread that periodically saves the configuration.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ajax / UnlikeAjaxPage.java
index a6a325a..84b0593 100644 (file)
@@ -33,9 +33,10 @@ public class UnlikeAjaxPage extends JsonPage {
         * Creates a new “unlike post” AJAX page.
         *
         * @param webInterface
+        *            The Sone web interface
         */
        public UnlikeAjaxPage(WebInterface webInterface) {
-               super("ajax/unlike.ajax", webInterface);
+               super("unlike.ajax", webInterface);
        }
 
        /**
@@ -46,20 +47,22 @@ public class UnlikeAjaxPage extends JsonPage {
                String type = request.getHttpRequest().getParam("type", null);
                String id = request.getHttpRequest().getParam(type, null);
                if ((id == null) || (id.length() == 0)) {
-                       return new JsonObject().put("success", false).put("error", "invalid-" + type + "-id");
+                       return createErrorJsonObject("invalid-" + type + "-id");
                }
                Sone currentSone = getCurrentSone(request.getToadletContext());
                if (currentSone == null) {
-                       return new JsonObject().put("success", false).put("error", "auth-required");
+                       return createErrorJsonObject("auth-required");
                }
                if ("post".equals(type)) {
                        currentSone.removeLikedPostId(id);
+                       webInterface.getCore().touchConfiguration();
                } else if ("reply".equals(type)) {
                        currentSone.removeLikedReplyId(id);
+                       webInterface.getCore().touchConfiguration();
                } else {
-                       return new JsonObject().put("success", false).put("error", "invalid-type");
+                       return createErrorJsonObject("invalid-type");
                }
-               return new JsonObject().put("success", true);
+               return createSuccessJsonObject();
        }
 
 }