This resolves #282.
/** The update checker. */
private final UpdateChecker updateChecker;
+ /** The trust updater. */
+ private final TrustUpdater trustUpdater;
+
/** The FCP interface. */
private volatile FcpInterface fcpInterface;
* @param identityManager
* The identity manager
*/
- public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager) {
+ public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager, TrustUpdater trustUpdater) {
super("Sone Core");
this.configuration = configuration;
this.freenetInterface = freenetInterface;
this.soneDownloader = new SoneDownloader(this, freenetInterface);
this.imageInserter = new ImageInserter(this, freenetInterface);
this.updateChecker = new UpdateChecker(freenetInterface);
+ this.trustUpdater = trustUpdater;
}
//
logger.log(Level.WARNING, String.format("Tried to get trust from remote Sone: %s", origin));
return null;
}
+ trustUpdater.getTrust((OwnIdentity) origin.getIdentity(), target.getIdentity());
return target.getIdentity().getTrust((OwnIdentity) origin.getIdentity());
}
*/
public void setTrust(Sone origin, Sone target, int trustValue) {
Validation.begin().isNotNull("Trust Origin", origin).check().isInstanceOf("Trust Origin", origin.getIdentity(), OwnIdentity.class).isNotNull("Trust Target", target).isLessOrEqual("Trust Value", trustValue, 100).isGreaterOrEqual("Trust Value", trustValue, -100).check();
- try {
- ((OwnIdentity) origin.getIdentity()).setTrust(target.getIdentity(), trustValue, preferences.getTrustComment());
- } catch (WebOfTrustException wote1) {
- logger.log(Level.WARNING, String.format("Could not set trust for Sone: %s", target), wote1);
- }
+ trustUpdater.setTrust((OwnIdentity) origin.getIdentity(), target.getIdentity(), trustValue, preferences.getTrustComment());
}
/**
*/
public void removeTrust(Sone origin, Sone target) {
Validation.begin().isNotNull("Trust Origin", origin).isNotNull("Trust Target", target).check().isInstanceOf("Trust Origin Identity", origin.getIdentity(), OwnIdentity.class).check();
- try {
- ((OwnIdentity) origin.getIdentity()).removeTrust(target.getIdentity());
- } catch (WebOfTrustException wote1) {
- logger.log(Level.WARNING, String.format("Could not remove trust for Sone: %s", target), wote1);
- }
+ trustUpdater.setTrust((OwnIdentity) origin.getIdentity(), target.getIdentity(), null, null);
}
/**
loadConfiguration();
updateChecker.addUpdateListener(this);
updateChecker.start();
+ trustUpdater.start();
}
/**
soneInserter.stop();
}
}
+ trustUpdater.stop();
updateChecker.stop();
updateChecker.removeUpdateListener(this);
soneDownloader.stop();
configuration.getStringValue("Option/TrustComment").setValue(options.getStringOption("TrustComment").getReal());
configuration.getBooleanValue("Option/ActivateFcpInterface").setValue(options.getBooleanOption("ActivateFcpInterface").getReal());
configuration.getIntValue("Option/FcpFullAccessRequired").setValue(options.getIntegerOption("FcpFullAccessRequired").getReal());
- configuration.getBooleanValue("Option/SoneRescueMode").setValue(options.getBooleanOption("SoneRescueMode").getReal());
- configuration.getBooleanValue("Option/ClearOnNextRestart").setValue(options.getBooleanOption("ClearOnNextRestart").getReal());
- configuration.getBooleanValue("Option/ReallyClearOnNextRestart").setValue(options.getBooleanOption("ReallyClearOnNextRestart").getReal());
/* save known Sones. */
int soneCounter = 0;
}
}));
- options.addBooleanOption("SoneRescueMode", new DefaultOption<Boolean>(false));
- options.addBooleanOption("ClearOnNextRestart", new DefaultOption<Boolean>(false));
- options.addBooleanOption("ReallyClearOnNextRestart", new DefaultOption<Boolean>(false));
-
- /* read options from configuration. */
- options.getBooleanOption("ClearOnNextRestart").set(configuration.getBooleanValue("Option/ClearOnNextRestart").getValue(null));
- options.getBooleanOption("ReallyClearOnNextRestart").set(configuration.getBooleanValue("Option/ReallyClearOnNextRestart").getValue(null));
- boolean clearConfiguration = options.getBooleanOption("ClearOnNextRestart").get() && options.getBooleanOption("ReallyClearOnNextRestart").get();
- options.getBooleanOption("ClearOnNextRestart").set(null);
- options.getBooleanOption("ReallyClearOnNextRestart").set(null);
- if (clearConfiguration) {
- /* stop loading the configuration. */
- return;
- }
loadConfigurationValue("InsertionDelay");
loadConfigurationValue("PostsPerPage");
options.getStringOption("TrustComment").set(configuration.getStringValue("Option/TrustComment").getValue(null));
options.getBooleanOption("ActivateFcpInterface").set(configuration.getBooleanValue("Option/ActivateFcpInterface").getValue(null));
options.getIntegerOption("FcpFullAccessRequired").set(configuration.getIntValue("Option/FcpFullAccessRequired").getValue(null));
- options.getBooleanOption("SoneRescueMode").set(configuration.getBooleanValue("Option/SoneRescueMode").getValue(null));
/* load known Sones. */
int soneCounter = 0;
return this;
}
- /**
- * Returns whether Sone should clear its settings on the next restart.
- * In order to be effective, {@link #isReallyClearOnNextRestart()} needs
- * to return {@code true} as well!
- *
- * @return {@code true} if Sone should clear its settings on the next
- * restart, {@code false} otherwise
- */
- public boolean isClearOnNextRestart() {
- return options.getBooleanOption("ClearOnNextRestart").get();
- }
-
- /**
- * Sets whether Sone will clear its settings on the next restart.
- *
- * @param clearOnNextRestart
- * {@code true} if Sone should clear its settings on the next
- * restart, {@code false} otherwise
- * @return This preferences
- */
- public Preferences setClearOnNextRestart(Boolean clearOnNextRestart) {
- options.getBooleanOption("ClearOnNextRestart").set(clearOnNextRestart);
- return this;
- }
-
- /**
- * Returns whether Sone should really clear its settings on next
- * restart. This is a confirmation option that needs to be set in
- * addition to {@link #isClearOnNextRestart()} in order to clear Sone’s
- * settings on the next restart.
- *
- * @return {@code true} if Sone should really clear its settings on the
- * next restart, {@code false} otherwise
- */
- public boolean isReallyClearOnNextRestart() {
- return options.getBooleanOption("ReallyClearOnNextRestart").get();
- }
-
- /**
- * Sets whether Sone should really clear its settings on the next
- * restart.
- *
- * @param reallyClearOnNextRestart
- * {@code true} if Sone should really clear its settings on
- * the next restart, {@code false} otherwise
- * @return This preferences
- */
- public Preferences setReallyClearOnNextRestart(Boolean reallyClearOnNextRestart) {
- options.getBooleanOption("ReallyClearOnNextRestart").set(reallyClearOnNextRestart);
- return this;
- }
-
}
}
--- /dev/null
+/*
+ * Sone - TrustUpdater.java - Copyright © 2012 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.core;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import net.pterodactylus.sone.freenet.plugin.PluginException;
+import net.pterodactylus.sone.freenet.wot.DefaultIdentity;
+import net.pterodactylus.sone.freenet.wot.Identity;
+import net.pterodactylus.sone.freenet.wot.OwnIdentity;
+import net.pterodactylus.sone.freenet.wot.Trust;
+import net.pterodactylus.sone.freenet.wot.WebOfTrustConnector;
+import net.pterodactylus.sone.freenet.wot.WebOfTrustException;
+import net.pterodactylus.util.logging.Logging;
+import net.pterodactylus.util.service.AbstractService;
+
+/**
+ * Updates identity’s trust in a background thread because getting updates from
+ * the WebOfTrust plugin can potentially last quite long.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class TrustUpdater extends AbstractService {
+
+ /** The logger. */
+ private static final Logger logger = Logging.getLogger(TrustUpdater.class);
+
+ /** Stop job. */
+ private static final TrustUpdateJob stopJob = new TrustUpdateJob(null, null);
+
+ /** The web of trust connector. */
+ private final WebOfTrustConnector webOfTrustConnector;
+
+ /** The queue for jobs. */
+ private final BlockingQueue<TrustUpdateJob> updateJobs = new LinkedBlockingQueue<TrustUpdateJob>();
+
+ /**
+ * Creates a new trust updater.
+ *
+ * @param webOfTrustConnector
+ * The web of trust connector
+ */
+ public TrustUpdater(WebOfTrustConnector webOfTrustConnector) {
+ super("Trust Updater");
+ this.webOfTrustConnector = webOfTrustConnector;
+ }
+
+ //
+ // ACTIONS
+ //
+
+ /**
+ * Retrieves the trust relation between the truster and the trustee. This
+ * method will return immediately and perform a trust update in the
+ * background.
+ *
+ * @param truster
+ * The identity giving the trust
+ * @param trustee
+ * The identity receiving the trust
+ */
+ public void getTrust(OwnIdentity truster, Identity trustee) {
+ GetTrustJob getTrustJob = new GetTrustJob(truster, trustee);
+ if (!updateJobs.contains(getTrustJob)) {
+ logger.log(Level.FINER, "Adding Trust Update Job: " + getTrustJob);
+ try {
+ updateJobs.put(getTrustJob);
+ } catch (InterruptedException ie1) {
+ /* the queue is unbounded so it should never block. */
+ }
+ }
+ }
+
+ /**
+ * Updates the trust relation between the truster and the trustee. This
+ * method will return immediately and perform a trust update in the
+ * background.
+ *
+ * @param truster
+ * The identity giving the trust
+ * @param trustee
+ * The identity receiving the trust
+ * @param score
+ * The new level of trust (from -100 to 100, may be {@code null}
+ * to remove the trust completely)
+ * @param comment
+ * The comment of the trust relation
+ */
+ public void setTrust(OwnIdentity truster, Identity trustee, Integer score, String comment) {
+ SetTrustJob setTrustJob = new SetTrustJob(truster, trustee, score, comment);
+ if (updateJobs.contains(setTrustJob)) {
+ updateJobs.remove(setTrustJob);
+ }
+ logger.log(Level.FINER, "Adding Trust Update Job: " + setTrustJob);
+ try {
+ updateJobs.put(setTrustJob);
+ } catch (InterruptedException e) {
+ /* the queue is unbounded so it should never block. */
+ }
+ }
+
+ //
+ // SERVICE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void serviceRun() {
+ while (!shouldStop()) {
+ try {
+ TrustUpdateJob updateJob = updateJobs.take();
+ if (shouldStop() || (updateJob == stopJob)) {
+ break;
+ }
+ logger.log(Level.FINE, "Running Trust Update Job: " + updateJob);
+ long startTime = System.currentTimeMillis();
+ updateJob.run();
+ long endTime = System.currentTimeMillis();
+ logger.log(Level.FINE, "Trust Update Job finished, took " + (endTime - startTime) + " ms.");
+ } catch (InterruptedException ie1) {
+ /* happens, ignore, loop. */
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void serviceStop() {
+ try {
+ updateJobs.put(stopJob);
+ } catch (InterruptedException ie1) {
+ /* the queue is unbounded so it should never block. */
+ }
+ }
+
+ /**
+ * Base class for trust update jobs.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+ private static class TrustUpdateJob {
+
+ /** The identity giving the trust. */
+ protected final OwnIdentity truster;
+
+ /** The identity receiving the trust. */
+ protected final Identity trustee;
+
+ /**
+ * Creates a new trust update job.
+ *
+ * @param truster
+ * The identity giving the trust
+ * @param trustee
+ * The identity receiving the trust
+ */
+ public TrustUpdateJob(OwnIdentity truster, Identity trustee) {
+ this.truster = truster;
+ this.trustee = trustee;
+ }
+
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Performs the actual update operation.
+ * <p>
+ * The implementation of this class does nothing.
+ */
+ public void run() {
+ /* does nothing. */
+ }
+
+ //
+ // OBJECT METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object object) {
+ if ((object == null) || !object.getClass().equals(getClass())) {
+ return false;
+ }
+ TrustUpdateJob updateJob = (TrustUpdateJob) object;
+ return ((truster == null) ? (updateJob.truster == null) : updateJob.truster.equals(truster)) && ((trustee == null) ? (updateJob.trustee == null) : updateJob.trustee.equals(trustee));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return getClass().hashCode() ^ ((truster == null) ? 0 : truster.hashCode()) ^ ((trustee == null) ? 0 : trustee.hashCode());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return String.format("%s[truster=%s,trustee=%s]", getClass().getSimpleName(), (truster == null) ? null : truster.getId(), (trustee == null) ? null : trustee.getId());
+ }
+
+ }
+
+ /**
+ * Update job that sets the trust relation between two identities.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+ private class SetTrustJob extends TrustUpdateJob {
+
+ /** The score of the relation. */
+ private final Integer score;
+
+ /** The comment of the relation. */
+ private final String comment;
+
+ /**
+ * Creates a new set trust job.
+ *
+ * @param truster
+ * The identity giving the trust
+ * @param trustee
+ * The identity receiving the trust
+ * @param score
+ * The score of the trust (from -100 to 100, may be
+ * {@code null} to remote the trust relation completely)
+ * @param comment
+ * The comment of the trust relation
+ */
+ public SetTrustJob(OwnIdentity truster, Identity trustee, Integer score, String comment) {
+ super(truster, trustee);
+ this.score = score;
+ this.comment = comment;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @SuppressWarnings("synthetic-access")
+ public void run() {
+ try {
+ if (score != null) {
+ if (trustee instanceof DefaultIdentity) {
+ ((DefaultIdentity) trustee).setTrust(truster, new Trust(score, null, 0));
+ }
+ webOfTrustConnector.setTrust(truster, trustee, score, comment);
+ } else {
+ if (trustee instanceof DefaultIdentity) {
+ ((DefaultIdentity) trustee).setTrust(truster, null);
+ }
+ webOfTrustConnector.removeTrust(truster, trustee);
+ }
+ } catch (WebOfTrustException wote1) {
+ logger.log(Level.WARNING, "Could not set Trust value for " + truster + " -> " + trustee + " to " + score + " (" + comment + ")!", wote1);
+ }
+ }
+
+ }
+
+ /**
+ * Update job that retrieves the trust relation between two identities.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+ private class GetTrustJob extends TrustUpdateJob {
+
+ /**
+ * Creates a new trust update job.
+ *
+ * @param truster
+ * The identity giving the trust
+ * @param trustee
+ * The identity receiving the trust
+ */
+ public GetTrustJob(OwnIdentity truster, Identity trustee) {
+ super(truster, trustee);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @SuppressWarnings("synthetic-access")
+ public void run() {
+ try {
+ Trust trust = webOfTrustConnector.getTrust(truster, trustee);
+ if (trustee instanceof DefaultIdentity) {
+ ((DefaultIdentity) trustee).setTrust(truster, trust);
+ }
+ } catch (PluginException pe1) {
+ logger.log(Level.WARNING, "Could not get Trust value for " + truster + " -> " + trustee + "!", pe1);
+ }
+ }
+ }
+
+}
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.logging.Level;
import java.util.logging.Logger;
-import net.pterodactylus.sone.freenet.plugin.PluginException;
-import net.pterodactylus.util.cache.CacheException;
-import net.pterodactylus.util.cache.CacheItem;
-import net.pterodactylus.util.cache.DefaultCacheItem;
-import net.pterodactylus.util.cache.MemoryCache;
-import net.pterodactylus.util.cache.ValueRetriever;
-import net.pterodactylus.util.cache.WritableCache;
-import net.pterodactylus.util.collection.TimedMap;
import net.pterodactylus.util.logging.Logging;
/**
/** Cached trust. */
/* synchronize on itself. */
- private final WritableCache<OwnIdentity, Trust> trustCache = new MemoryCache<OwnIdentity, Trust>(new ValueRetriever<OwnIdentity, Trust>() {
-
- @Override
- @SuppressWarnings("synthetic-access")
- public CacheItem<Trust> retrieve(OwnIdentity ownIdentity) throws CacheException {
- try {
- return new DefaultCacheItem<Trust>(webOfTrustConnector.getTrust(ownIdentity, DefaultIdentity.this));
- } catch (PluginException pe1) {
- throw new CacheException("Could not retrieve trust for OwnIdentity: " + ownIdentity, pe1);
- }
- }
-
- }, new TimedMap<OwnIdentity, CacheItem<Trust>>(60 * 60 * 1000));
+ private final Map<OwnIdentity, Trust> trustCache = new HashMap<OwnIdentity, Trust>();
/**
* Creates a new identity.
*/
@Override
public Trust getTrust(OwnIdentity ownIdentity) {
- try {
- synchronized (trustCache) {
- return trustCache.get(ownIdentity);
- }
- } catch (CacheException ce1) {
- logger.log(Level.WARNING, String.format("Could not get trust for OwnIdentity: %s", ownIdentity), ce1);
- return null;
+ synchronized (trustCache) {
+ return trustCache.get(ownIdentity);
}
}
* @param trust
* The trust received for this identity
*/
- void setTrustPrivate(OwnIdentity ownIdentity, Trust trust) {
+ public void setTrust(OwnIdentity ownIdentity, Trust trust) {
synchronized (trustCache) {
trustCache.put(ownIdentity, trust);
}
Validation.begin().isNotNull("Trust Target", target).isNotNull("Trust Comment", comment).isLessOrEqual("Trust Value", trustValue, 100).isGreaterOrEqual("Trust Value", trustValue, -100).check();
webOfTrustConnector.setTrust(this, target, trustValue, comment);
if (target instanceof DefaultIdentity) {
- ((DefaultIdentity) target).setTrustPrivate(this, new Trust(trustValue, trustValue, 0));
+ ((DefaultIdentity) target).setTrust(this, new Trust(trustValue, trustValue, 0));
}
}
Validation.begin().isNotNull("Trust Target", target).check();
webOfTrustConnector.removeTrust(this, target);
if (target instanceof DefaultIdentity) {
- ((DefaultIdentity) target).setTrustPrivate(this, new Trust(null, null, null));
+ ((DefaultIdentity) target).setTrust(this, new Trust(null, null, null));
}
}
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.core.FreenetInterface;
+import net.pterodactylus.sone.core.TrustUpdater;
import net.pterodactylus.sone.fcp.FcpInterface;
import net.pterodactylus.sone.freenet.PluginStoreConfigurationBackend;
import net.pterodactylus.sone.freenet.plugin.PluginConnector;
identityManager = new IdentityManager(webOfTrustConnector);
identityManager.setContext("Sone");
+ /* create trust updater. */
+ TrustUpdater trustUpdater = new TrustUpdater(webOfTrustConnector);
+ trustUpdater.init();
+
/* create core. */
- core = new Core(oldConfiguration, freenetInterface, identityManager);
+ core = new Core(oldConfiguration, freenetInterface, identityManager, trustUpdater);
/* create the web interface. */
webInterface = new WebInterface(this);
return false;
}
} else {
- return false;
+ /*
+ * a null trust means that the trust updater has not yet
+ * received a trust value for this relation. if we return false,
+ * the post feed will stay empty until the trust updater has
+ * received trust values. to prevent this we simply assume that
+ * posts are visible if there is no trust.
+ */
+ return true;
}
if ((!postSone.equals(sone)) && !sone.hasFriend(postSone.getId()) && !sone.equals(post.getRecipient())) {
return false;
Integer fcpFullAccessRequiredInteger = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("fcp-full-access-required", 1), preferences.getFcpFullAccessRequired().ordinal());
FullAccessRequired fcpFullAccessRequired = FullAccessRequired.values()[fcpFullAccessRequiredInteger];
preferences.setFcpFullAccessRequired(fcpFullAccessRequired);
- boolean clearOnNextRestart = Boolean.parseBoolean(request.getHttpRequest().getPartAsStringFailsafe("clear-on-next-restart", 5));
- preferences.setClearOnNextRestart(clearOnNextRestart);
- boolean reallyClearOnNextRestart = Boolean.parseBoolean(request.getHttpRequest().getPartAsStringFailsafe("really-clear-on-next-restart", 5));
- preferences.setReallyClearOnNextRestart(reallyClearOnNextRestart);
webInterface.getCore().touchConfiguration();
if (fieldErrors.isEmpty()) {
throw new RedirectException(getPath());
templateContext.set("trust-comment", preferences.getTrustComment());
templateContext.set("fcp-interface-active", preferences.isFcpInterfaceActive());
templateContext.set("fcp-full-access-required", preferences.getFcpFullAccessRequired().ordinal());
- templateContext.set("clear-on-next-restart", preferences.isClearOnNextRestart());
- templateContext.set("really-clear-on-next-restart", preferences.isReallyClearOnNextRestart());
}
}
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.freenet.wot.Trust;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.json.JsonObject;
return createErrorJsonObject("invalid-sone-id");
}
webInterface.getCore().distrustSone(currentSone, sone);
- Trust trust = webInterface.getCore().getTrust(currentSone, sone);
- if (trust == null) {
- return createErrorJsonObject("wot-plugin");
- }
- return createSuccessJsonObject().put("trustValue", trust.getExplicit());
+ return createSuccessJsonObject().put("trustValue", webInterface.getCore().getPreferences().getNegativeTrust());
}
}
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.freenet.wot.Trust;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.json.JsonObject;
return createErrorJsonObject("invalid-sone-id");
}
webInterface.getCore().trustSone(currentSone, sone);
- Trust trust = webInterface.getCore().getTrust(currentSone, sone);
- if (trust == null) {
- return createErrorJsonObject("wot-plugin");
- }
- return createSuccessJsonObject().put("trustValue", trust.getExplicit());
+ return createSuccessJsonObject().put("trustValue", webInterface.getCore().getPreferences().getPositiveTrust());
}
}
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.freenet.wot.Trust;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.json.JsonObject;
return createErrorJsonObject("invalid-sone-id");
}
webInterface.getCore().untrustSone(currentSone, sone);
- Trust trust = webInterface.getCore().getTrust(currentSone, sone);
- if (trust == null) {
- return createErrorJsonObject("wot-plugin");
- }
- return createSuccessJsonObject().put("trustValue", trust.getExplicit());
+ return createSuccessJsonObject().put("trustValue", (String) null);
}
}
<button type="submit" value="1"><%= View.Post.UnlikeLink|l10n|html></button>
</form>
<%if !post.sone.current>
- <span class='separator'>·</span>
- <form class="trust post-trust<%if post.sone.trust.assigned> hidden<%/if>" action="trust.html" method="post">
- <input type="hidden" name="formPassword" value="<% formPassword|html>" />
- <input type="hidden" name="returnPage" value="<% request.uri|html>" />
- <input type="hidden" name="sone" value="<% post.sone.id|html>" />
- <button type="submit" title="<%= View.Trust.Tooltip.Trust|l10n|html>">✓</button>
- </form>
- <form class="distrust post-distrust<%if post.sone.trust.assigned> hidden<%/if>" action="distrust.html" method="post">
- <input type="hidden" name="formPassword" value="<% formPassword|html>" />
- <input type="hidden" name="returnPage" value="<% request.uri|html>" />
- <input type="hidden" name="sone" value="<% post.sone.id|html>" />
- <button type="submit" title="<%= View.Trust.Tooltip.Distrust|l10n|html>">✗</button>
- </form>
- <form class="untrust post-untrust<%if !post.sone.trust.assigned> hidden<%/if>" action="untrust.html" method="post">
- <input type="hidden" name="formPassword" value="<% formPassword|html>" />
- <input type="hidden" name="returnPage" value="<% request.uri|html>" />
- <input type="hidden" name="sone" value="<% post.sone.id|html>" />
- <button type="submit" title="<%= View.Trust.Tooltip.Untrust|l10n|html>">↶</button>
- </form>
+ <%ifnull !post.sone.trust>
+ <span class='separator'>·</span>
+ <form class="trust post-trust<%if post.sone.trust.assigned> hidden<%/if>" action="trust.html" method="post">
+ <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+ <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+ <input type="hidden" name="sone" value="<% post.sone.id|html>" />
+ <button type="submit" title="<%= View.Trust.Tooltip.Trust|l10n|html>">✓</button>
+ </form>
+ <form class="distrust post-distrust<%if post.sone.trust.assigned> hidden<%/if>" action="distrust.html" method="post">
+ <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+ <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+ <input type="hidden" name="sone" value="<% post.sone.id|html>" />
+ <button type="submit" title="<%= View.Trust.Tooltip.Distrust|l10n|html>">✗</button>
+ </form>
+ <form class="untrust post-untrust<%if !post.sone.trust.assigned> hidden<%/if>" action="untrust.html" method="post">
+ <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+ <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+ <input type="hidden" name="sone" value="<% post.sone.id|html>" />
+ <button type="submit" title="<%= View.Trust.Tooltip.Untrust|l10n|html>">↶</button>
+ </form>
+ <%/if>
<%/if>
<%/if>
<%if post.sone.local>
<button type="submit" value="1"><%= View.Post.UnlikeLink|l10n|html></button>
</form>
<%if !reply.sone.current>
- <span class='separator'>·</span>
- <form class="trust reply-trust<%if reply.sone.trust.assigned> hidden<%/if>" action="trust.html" method="post">
- <input type="hidden" name="formPassword" value="<% formPassword|html>" />
- <input type="hidden" name="returnPage" value="<% request.uri|html>" />
- <input type="hidden" name="sone" value="<% reply.sone.id|html>" />
- <button type="submit" title="<%= View.Trust.Tooltip.Trust|l10n|html>">✓</button>
- </form>
- <form class="distrust reply-distrust<%if reply.sone.trust.assigned> hidden<%/if>" action="distrust.html" method="post">
- <input type="hidden" name="formPassword" value="<% formPassword|html>" />
- <input type="hidden" name="returnPage" value="<% request.uri|html>" />
- <input type="hidden" name="sone" value="<% reply.sone.id|html>" />
- <button type="submit" title="<%= View.Trust.Tooltip.Distrust|l10n|html>">✗</button>
- </form>
- <form class="untrust reply-untrust<%if !reply.sone.trust.assigned> hidden<%/if>" action="untrust.html" method="post">
- <input type="hidden" name="formPassword" value="<% formPassword|html>" />
- <input type="hidden" name="returnPage" value="<% request.uri|html>" />
- <input type="hidden" name="sone" value="<% reply.sone.id|html>" />
- <button type="submit" title="<%= View.Trust.Tooltip.Untrust|l10n|html>">↶</button>
- </form>
+ <%ifnull !reply.sone.trust>
+ <span class='separator'>·</span>
+ <form class="trust reply-trust<%if reply.sone.trust.assigned> hidden<%/if>" action="trust.html" method="post">
+ <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+ <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+ <input type="hidden" name="sone" value="<% reply.sone.id|html>" />
+ <button type="submit" title="<%= View.Trust.Tooltip.Trust|l10n|html>">✓</button>
+ </form>
+ <form class="distrust reply-distrust<%if reply.sone.trust.assigned> hidden<%/if>" action="distrust.html" method="post">
+ <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+ <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+ <input type="hidden" name="sone" value="<% reply.sone.id|html>" />
+ <button type="submit" title="<%= View.Trust.Tooltip.Distrust|l10n|html>">✗</button>
+ </form>
+ <form class="untrust reply-untrust<%if !reply.sone.trust.assigned> hidden<%/if>" action="untrust.html" method="post">
+ <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+ <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+ <input type="hidden" name="sone" value="<% reply.sone.id|html>" />
+ <button type="submit" title="<%= View.Trust.Tooltip.Untrust|l10n|html>">↶</button>
+ </form>
+ <%/if>
<%/if>
<%/if>
<%if reply.sone.local>
</select>
</p>
- <h2><%= Page.Options.Section.Cleaning.Title|l10n|html></h2>
-
- <p><%= Page.Options.Option.ClearOnNextRestart.Description|l10n|html|replace needle=="{strong}" replacement=="<strong>"|replace needle=="{/strong}" replacement=="</strong>"></p>
- <p><select name="clear-on-next-restart"><option disabled="disabled"><%= WebInterface.SelectBox.Choose|l10n|html></option><option value="true"<%if clear-on-next-restart> selected="selected"<%/if>><%= WebInterface.SelectBox.Yes|l10n|html></option><option value="false"<%if ! clear-on-next-restart> selected="selected"<%/if>><%= WebInterface.SelectBox.No|l10n|html></option></select>
-
- <p><%= Page.Options.Option.ReallyClearOnNextRestart.Description|l10n|html|replace needle=="{strong}" replacement=="<strong>"|replace needle=="{/strong}" replacement=="</strong>"></p>
- <p><select name="really-clear-on-next-restart"><option disabled="disabled"><%= WebInterface.SelectBox.Choose|l10n|html></option><option value="true"<%if really-clear-on-next-restart> selected="selected"<%/if>><%= WebInterface.SelectBox.Yes|l10n|html></option><option value="false"<%if ! really-clear-on-next-restart> selected="selected"<%/if>><%= WebInterface.SelectBox.No|l10n|html></option></select>
-
<p><button type="submit"><%= Page.Options.Button.Save|l10n|html></button></p>
</form>