Add method to check for the remoteness of a Sone by its ID.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index 52b885e..af1523a 100644 (file)
@@ -306,6 +306,20 @@ public class Core implements IdentityListener {
        }
 
        /**
+        * Returns whether the Sone with the given ID is a remote Sone.
+        *
+        * @param id
+        *            The ID of the Sone to check
+        * @return {@code true} if the Sone with the given ID is a remote Sone,
+        *         {@code false} otherwise
+        */
+       public boolean isRemoteSone(String id) {
+               synchronized (remoteSones) {
+                       return remoteSones.containsKey(id);
+               }
+       }
+
+       /**
         * Returns the post with the given ID.
         *
         * @param postId
@@ -499,6 +513,7 @@ public class Core implements IdentityListener {
                        sone.setLatestEdition(Numbers.safeParseLong(identity.getProperty("Sone.LatestEdition"), (long) 0));
                        remoteSones.put(identity.getId(), sone);
                        soneDownloader.addSone(sone);
+                       setSoneStatus(sone, SoneStatus.unknown);
                        new Thread(new Runnable() {
 
                                @Override
@@ -508,7 +523,6 @@ public class Core implements IdentityListener {
                                }
 
                        }, "Sone Downloader").start();
-                       setSoneStatus(sone, SoneStatus.idle);
                        return sone;
                }
        }