Use web package from utils.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ajax / GetNotificationAjaxPage.java
index 1406c3a..198a04f 100644 (file)
@@ -27,6 +27,7 @@ import net.pterodactylus.sone.main.SonePlugin;
 import net.pterodactylus.sone.notify.ListNotification;
 import net.pterodactylus.sone.notify.ListNotificationFilters;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.notify.TemplateNotification;
@@ -75,16 +76,18 @@ public class GetNotificationAjaxPage extends JsonPage {
         */
        @Override
        @SuppressWarnings("unchecked")
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String[] notificationIds = request.getHttpRequest().getParam("notifications").split(",");
                JsonObject jsonNotifications = new JsonObject();
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                for (String notificationId : notificationIds) {
                        Notification notification = webInterface.getNotifications().getNotification(notificationId);
                        if ("new-post-notification".equals(notificationId)) {
-                               notification = ListNotificationFilters.filterNewPostNotification((ListNotification<Post>) notification, currentSone);
+                               notification = ListNotificationFilters.filterNewPostNotification((ListNotification<Post>) notification, currentSone, false);
                        } else if ("new-reply-notification".equals(notificationId)) {
                                notification = ListNotificationFilters.filterNewReplyNotification((ListNotification<Reply>) notification, currentSone);
+                       } else if ("mention-notification".equals(notificationId)) {
+                               notification = ListNotificationFilters.filterNewPostNotification((ListNotification<Post>) notification, currentSone, false);
                        }
                        if (notification == null) {
                                // TODO - show error
@@ -108,13 +111,14 @@ public class GetNotificationAjaxPage extends JsonPage {
         *            The notification to create a JSON object
         * @return The JSON object
         */
-       private JsonObject createJsonNotification(Request request, Notification notification) {
+       private JsonObject createJsonNotification(FreenetRequest request, Notification notification) {
                JsonObject jsonNotification = new JsonObject();
                jsonNotification.put("id", notification.getId());
                StringWriter notificationWriter = new StringWriter();
                try {
                        if (notification instanceof TemplateNotification) {
                                TemplateContext templateContext = webInterface.getTemplateContextFactory().createTemplateContext().mergeContext(((TemplateNotification) notification).getTemplateContext());
+                               templateContext.set("core", webInterface.getCore());
                                templateContext.set("currentSone", webInterface.getCurrentSone(request.getToadletContext(), false));
                                templateContext.set("localSones", webInterface.getCore().getLocalSones());
                                templateContext.set("request", request);