Don’t expose the plugin version directly
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index 4e4f6fa..b7e3287 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - WebInterface.java - Copyright © 2010–2015 David Roden
+ * Sone - WebInterface.java - Copyright © 2010–2016 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,7 +21,6 @@ import static com.google.common.collect.FluentIterable.from;
 import static java.util.logging.Logger.getLogger;
 import static net.pterodactylus.util.template.TemplateParser.parse;
 
-import java.io.IOException;
 import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -36,7 +35,6 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -75,7 +73,7 @@ import net.pterodactylus.sone.main.Loaders;
 import net.pterodactylus.sone.main.ReparseFilter;
 import net.pterodactylus.sone.main.SonePlugin;
 import net.pterodactylus.sone.notify.ListNotification;
-import net.pterodactylus.sone.notify.ListNotificationFilters;
+import net.pterodactylus.sone.notify.ListNotificationFilter;
 import net.pterodactylus.sone.notify.PostVisibilityFilter;
 import net.pterodactylus.sone.notify.ReplyVisibilityFilter;
 import net.pterodactylus.sone.template.AlbumAccessor;
@@ -201,7 +199,7 @@ public class WebInterface {
        /** The parser filter. */
        private final ParserFilter parserFilter;
 
-       private final ListNotificationFilters listNotificationFilters;
+       private final ListNotificationFilter listNotificationFilter;
        private final PostVisibilityFilter postVisibilityFilter;
        private final ReplyVisibilityFilter replyVisibilityFilter;
 
@@ -254,10 +252,10 @@ public class WebInterface {
         *            The Sone plugin
         */
        @Inject
-       public WebInterface(SonePlugin sonePlugin, Loaders loaders, ListNotificationFilters listNotificationFilters, PostVisibilityFilter postVisibilityFilter, ReplyVisibilityFilter replyVisibilityFilter) {
+       public WebInterface(SonePlugin sonePlugin, Loaders loaders, ListNotificationFilter listNotificationFilter, PostVisibilityFilter postVisibilityFilter, ReplyVisibilityFilter replyVisibilityFilter) {
                this.sonePlugin = sonePlugin;
                this.loaders = loaders;
-               this.listNotificationFilters = listNotificationFilters;
+               this.listNotificationFilter = listNotificationFilter;
                this.postVisibilityFilter = postVisibilityFilter;
                this.replyVisibilityFilter = replyVisibilityFilter;
                formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
@@ -475,7 +473,7 @@ public class WebInterface {
 
        @Nonnull
        public Collection<Notification> getNotifications(@Nullable Sone currentSone) {
-               return listNotificationFilters.filterNotifications(notificationManager.getNotifications(), currentSone);
+               return listNotificationFilter.filterNotifications(notificationManager.getNotifications(), currentSone);
        }
 
        /**
@@ -719,7 +717,7 @@ public class WebInterface {
                pageToadlets.add(pageToadletFactory.createPageToadlet(new LogoutPage(emptyTemplate, this), "Logout"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new OptionsPage(optionsTemplate, this), "Options"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new RescuePage(rescueTemplate, this), "Rescue"));
-               pageToadlets.add(pageToadletFactory.createPageToadlet(new AboutPage(aboutTemplate, this, SonePlugin.VERSION, SonePlugin.getYear(), SonePlugin.getHomepage()), "About"));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new AboutPage(aboutTemplate, this, SonePlugin.getPluginVersion(), SonePlugin.getYear(), SonePlugin.getHomepage()), "About"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyImageTitle.html", emptyImageTitleTemplate, "Page.EmptyImageTitle.Title", this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyAlbumTitle.html", emptyAlbumTitleTemplate, "Page.EmptyAlbumTitle.Title", this)));
@@ -795,14 +793,10 @@ public class WebInterface {
        private Collection<Sone> getMentionedSones(String text) {
                /* we need no context to find mentioned Sones. */
                Set<Sone> mentionedSones = new HashSet<Sone>();
-               try {
-                       for (Part part : soneTextParser.parse(null, new StringReader(text))) {
-                               if (part instanceof SonePart) {
-                                       mentionedSones.add(((SonePart) part).getSone());
-                               }
+               for (Part part : soneTextParser.parse(text, null)) {
+                       if (part instanceof SonePart) {
+                               mentionedSones.add(((SonePart) part).getSone());
                        }
-               } catch (IOException ioe1) {
-                       logger.log(Level.WARNING, String.format("Could not parse post text: %s", text), ioe1);
                }
                return Collections2.filter(mentionedSones, Sone.LOCAL_SONE_FILTER);
        }
@@ -939,12 +933,6 @@ public class WebInterface {
        @Subscribe
        public void soneRemoved(SoneRemovedEvent soneRemovedEvent) {
                newSoneNotification.remove(soneRemovedEvent.sone());
-               for (Post post : soneRemovedEvent.sone().getPosts()) {
-                       removePost(post);
-               }
-               for (PostReply postReply : soneRemovedEvent.sone().getReplies()) {
-                       removeReply(postReply);
-               }
        }
 
        @Subscribe