X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=53b67000d1ac96fb06ff0068561f41435b072b19;hp=75b108b6cd07a7307db7af74d55d697636af1714;hb=63a1491b93ba8c2541ff92aab80e27cd41eda2fb;hpb=640c0111f7b387c33bc7933c2fa898ceb0b32796 diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 75b108b..53b6700 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -25,6 +25,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; @@ -876,6 +877,9 @@ public class Core implements IdentityListener, UpdateListener { return null; } Sone sone = addLocalSone(ownIdentity); + sone.getOptions().addBooleanOption("AutoFollow", new DefaultOption(false)); + sone.addFriend("nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI"); + saveSone(sone); return sone; } @@ -920,7 +924,7 @@ public class Core implements IdentityListener, UpdateListener { @Override @SuppressWarnings("synthetic-access") public void run() { - soneDownloader.fetchSone(sone); + soneDownloader.fetchSone(sone, sone.getRequestUri()); } }, "Sone Downloader").start(); @@ -1169,6 +1173,9 @@ public class Core implements IdentityListener, UpdateListener { return; } + /* initialize options. */ + sone.getOptions().addBooleanOption("AutoFollow", new DefaultOption(false)); + /* load Sone. */ String sonePrefix = "Sone/" + sone.getId(); Long soneTime = configuration.getLongValue(sonePrefix + "/Time").getValue(null); @@ -1269,7 +1276,6 @@ public class Core implements IdentityListener, UpdateListener { } /* load options. */ - sone.getOptions().addBooleanOption("AutoFollow", new DefaultOption(false)); sone.getOptions().getBooleanOption("AutoFollow").set(configuration.getBooleanValue(sonePrefix + "/Options/AutoFollow").getValue(null)); /* if we’re still here, Sone was loaded successfully. */ @@ -1493,6 +1499,7 @@ public class Core implements IdentityListener, UpdateListener { synchronized (posts) { posts.remove(post.getId()); } + coreListenerManager.firePostRemoved(post); synchronized (newPosts) { markPostKnown(post); knownPosts.remove(post.getId()); @@ -1762,7 +1769,7 @@ public class Core implements IdentityListener, UpdateListener { } })); - options.addIntegerOption("PostsPerPage", new DefaultOption(25)); + options.addIntegerOption("PostsPerPage", new DefaultOption(10)); options.addIntegerOption("PositiveTrust", new DefaultOption(75)); options.addIntegerOption("NegativeTrust", new DefaultOption(-25)); options.addStringOption("TrustComment", new DefaultOption("Set from Sone Web Interface")); @@ -1902,6 +1909,7 @@ public class Core implements IdentityListener, UpdateListener { public void run() { Sone sone = getRemoteSone(identity.getId()); sone.setIdentity(identity); + sone.setLatestEdition(Numbers.safeParseLong(identity.getProperty("Sone.LatestEdition"), sone.getLatestEdition())); soneDownloader.addSone(sone); soneDownloader.fetchSone(sone); } @@ -1914,6 +1922,48 @@ public class Core implements IdentityListener, UpdateListener { @Override public void identityRemoved(OwnIdentity ownIdentity, Identity identity) { trustedIdentities.get(ownIdentity).remove(identity); + boolean foundIdentity = false; + for (Entry> trustedIdentity : trustedIdentities.entrySet()) { + if (trustedIdentity.getKey().equals(ownIdentity)) { + continue; + } + if (trustedIdentity.getValue().contains(identity)) { + foundIdentity = true; + } + } + if (foundIdentity) { + /* some local identity still trusts this identity, don’t remove. */ + return; + } + Sone sone = getSone(identity.getId(), false); + if (sone == null) { + /* TODO - we don’t have the Sone anymore. should this happen? */ + return; + } + synchronized (posts) { + synchronized (newPosts) { + for (Post post : sone.getPosts()) { + posts.remove(post.getId()); + newPosts.remove(post.getId()); + coreListenerManager.firePostRemoved(post); + } + } + } + synchronized (replies) { + synchronized (newReplies) { + for (Reply reply : sone.getReplies()) { + replies.remove(reply.getId()); + newReplies.remove(reply.getId()); + coreListenerManager.fireReplyRemoved(reply); + } + } + } + synchronized (remoteSones) { + remoteSones.remove(identity.getId()); + } + synchronized (newSones) { + newSones.remove(identity.getId()); + } } //