Merge branch 'release-0.6.6'
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index 0e62f77..08202d4 100644 (file)
@@ -58,6 +58,7 @@ import net.pterodactylus.sone.template.RequestChangeFilter;
 import net.pterodactylus.sone.template.SoneAccessor;
 import net.pterodactylus.sone.template.SubstringFilter;
 import net.pterodactylus.sone.template.TrustAccessor;
+import net.pterodactylus.sone.template.UniqueElementFilter;
 import net.pterodactylus.sone.template.UnknownDateFilter;
 import net.pterodactylus.sone.text.Part;
 import net.pterodactylus.sone.text.SonePart;
@@ -228,6 +229,7 @@ public class WebInterface implements CoreListener {
                templateContextFactory.addFilter("sort", new CollectionSortFilter());
                templateContextFactory.addFilter("replyGroup", new ReplyGroupFilter());
                templateContextFactory.addFilter("in", new ContainsFilter());
+               templateContextFactory.addFilter("unique", new UniqueElementFilter());
                templateContextFactory.addProvider(Provider.TEMPLATE_CONTEXT_PROVIDER);
                templateContextFactory.addProvider(new ClassPathTemplateProvider());
                templateContextFactory.addTemplateObject("webInterface", this);
@@ -866,7 +868,9 @@ public class WebInterface implements CoreListener {
        public void soneInserting(Sone sone) {
                TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
                soneInsertNotification.set("soneStatus", "inserting");
-               notificationManager.addNotification(soneInsertNotification);
+               if (sone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
+                       notificationManager.addNotification(soneInsertNotification);
+               }
        }
 
        /**
@@ -877,7 +881,9 @@ public class WebInterface implements CoreListener {
                TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
                soneInsertNotification.set("soneStatus", "inserted");
                soneInsertNotification.set("insertDuration", insertDuration / 1000);
-               notificationManager.addNotification(soneInsertNotification);
+               if (sone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
+                       notificationManager.addNotification(soneInsertNotification);
+               }
        }
 
        /**
@@ -885,7 +891,12 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void soneInsertAborted(Sone sone, Throwable cause) {
-               notificationManager.addNotification(getSoneInsertNotification(sone).set("soneStatus", "insert-aborted").set("insert-error", cause));
+               TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
+               soneInsertNotification.set("soneStatus", "insert-aborted");
+               soneInsertNotification.set("insert-error", cause);
+               if (sone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
+                       notificationManager.addNotification(soneInsertNotification);
+               }
        }
 
        /**