Use dependency injection to create Sone instance.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index 00f8cf9..42a383f 100644 (file)
@@ -131,6 +131,9 @@ import net.pterodactylus.util.version.Version;
 import net.pterodactylus.util.web.RedirectPage;
 import net.pterodactylus.util.web.StaticPage;
 import net.pterodactylus.util.web.TemplatePage;
+
+import com.google.inject.Inject;
+
 import freenet.clients.http.SessionManager;
 import freenet.clients.http.SessionManager.Session;
 import freenet.clients.http.ToadletContainer;
@@ -215,6 +218,7 @@ public class WebInterface implements CoreListener {
         * @param sonePlugin
         *            The Sone plugin
         */
+       @Inject
        public WebInterface(SonePlugin sonePlugin) {
                this.sonePlugin = sonePlugin;
                formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
@@ -372,7 +376,7 @@ public class WebInterface implements CoreListener {
         *         currently logged in
         */
        public Sone getCurrentSone(ToadletContext toadletContext, boolean create) {
-               Set<Sone> localSones = getCore().getLocalSones();
+               Collection<Sone> localSones = getCore().getLocalSones();
                if (localSones.size() == 1) {
                        return localSones.iterator().next();
                }
@@ -789,7 +793,7 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void newPostFound(Post post) {
-               boolean isLocal = getCore().isLocalSone(post.getSone());
+               boolean isLocal = post.getSone().isLocal();
                if (isLocal) {
                        localPostNotification.add(post);
                } else {
@@ -811,7 +815,7 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void newReplyFound(PostReply reply) {
-               boolean isLocal = getCore().isLocalSone(reply.getSone());
+               boolean isLocal = reply.getSone().isLocal();
                if (isLocal) {
                        localReplyNotification.add(reply);
                } else {