X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=132e4a605249c1c826e7f148eeb8eeb480d1c4ad;hb=6fa3e26eb2deda14bd56dd343011b5735d449104;hp=5475dc6c7b46d1bde0842147aaa838985fd81571;hpb=ec75ca474a94a5d0fcfae5b6852c4f35864c04ef;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 5475dc6..132e4a6 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -106,6 +106,9 @@ public class Core implements IdentityListener { /* synchronize access on this on itself. */ private Map remoteSones = new HashMap(); + /** All new Sones. */ + private Set newSones = new HashSet(); + /** All posts. */ private Map posts = new HashMap(); @@ -306,6 +309,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 @@ -494,9 +511,15 @@ public class Core implements IdentityListener { return null; } synchronized (remoteSones) { + boolean newSone = !isRemoteSone(identity.getId()); final Sone sone = getRemoteSone(identity.getId()).setIdentity(identity); sone.setRequestUri(getSoneUri(identity.getRequestUri())); sone.setLatestEdition(Numbers.safeParseLong(identity.getProperty("Sone.LatestEdition"), (long) 0)); + if (newSone) { + synchronized (newSones) { + newSones.add(sone); + } + } remoteSones.put(identity.getId(), sone); soneDownloader.addSone(sone); setSoneStatus(sone, SoneStatus.unknown);