Fix likes only containing the likes of local Sones.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index e64f996..accfa1e 100644 (file)
@@ -643,8 +643,8 @@ public class Core extends AbstractService {
         *            The post to check for
         * @return All Sones that like the post
         */
-       public Set<Sone> getLikes(final Post post) {
-               return Filters.filteredSet(getSones(), new Filter<Sone>() {
+       public Collection<Sone> getLikes(final Post post) {
+               return Filters.filteredCollection(getKnownSones(), new Filter<Sone>() {
 
                        @Override
                        public boolean filterObject(Sone sone) {
@@ -660,8 +660,8 @@ public class Core extends AbstractService {
         *            The reply to check for
         * @return All Sones that like the reply
         */
-       public Set<Sone> getLikes(final Reply reply) {
-               return Filters.filteredSet(getSones(), new Filter<Sone>() {
+       public Collection<Sone> getLikes(final Reply reply) {
+               return Filters.filteredCollection(getKnownSones(), new Filter<Sone>() {
 
                        @Override
                        public boolean filterObject(Sone sone) {
@@ -712,6 +712,16 @@ public class Core extends AbstractService {
        //
 
        /**
+        * Adds some default Sones.
+        */
+       private void addDefaultSones() {
+               /* Sone’s Sone. */
+               loadSone("USK@eRHt0ceFsHjRZ11j6dd68RSdIvfd8f9YjJLZ9lnhEyo,iJWjIWh6TkMZm1NY8qBranKTIuwsCPkVPG6T6c6ft-I,AQACAAE/Sone/0");
+               /* Bombe’s Sone. */
+               loadSone("USK@RuW~uAO35Ipne896-1OmaVJNPuYE4ZIB5oZ5ziaU57A,7rV3uiyztXBDt03DCoRiNwiGjgFCJuznM9Okc1opURU,AQACAAE/Sone/15");
+       }
+
+       /**
         * Loads the configuration.
         */
        @SuppressWarnings("unchecked")
@@ -721,10 +731,7 @@ public class Core extends AbstractService {
                boolean firstStart = configuration.getBooleanValue("FirstStart").getValue(true);
                if (firstStart) {
                        logger.log(Level.INFO, "First start of Sone, adding a couple of default Sones…");
-                       /* Sone’s Sone. */
-                       loadSone("USK@eRHt0ceFsHjRZ11j6dd68RSdIvfd8f9YjJLZ9lnhEyo,iJWjIWh6TkMZm1NY8qBranKTIuwsCPkVPG6T6c6ft-I,AQACAAE/Sone/0");
-                       /* Bombe’s Sone. */
-                       loadSone("USK@RuW~uAO35Ipne896-1OmaVJNPuYE4ZIB5oZ5ziaU57A,7rV3uiyztXBDt03DCoRiNwiGjgFCJuznM9Okc1opURU,AQACAAE/Sone/15");
+                       addDefaultSones();
                        try {
                                configuration.getBooleanValue("FirstStart").setValue(false);
                        } catch (ConfigurationException ce1) {
@@ -755,6 +762,7 @@ public class Core extends AbstractService {
                options.getBooleanOption("ReallyClearOnNextRestart").set(null);
                if (clearConfiguration) {
                        /* stop loading the configuration. */
+                       addDefaultSones();
                        return;
                }