* The own identity to create a Sone from
* @return The added (or already existing) Sone
*/
- public Sone addLocalSone(OwnIdentity ownIdentity) {
+ public LocalSone addLocalSone(OwnIdentity ownIdentity) {
if (ownIdentity == null) {
logger.log(Level.WARNING, "Given OwnIdentity is null!");
return null;
logger.log(Level.SEVERE, String.format("Could not add “Sone” context to own identity: %s", ownIdentity));
return null;
}
- Sone sone = addLocalSone(ownIdentity);
+ LocalSone sone = addLocalSone(ownIdentity);
followSone(sone, "nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI");
touchConfiguration();
sone.setKnown(!newSone);
if (newSone) {
eventBus.post(new NewSoneFoundEvent(sone));
- for (Sone localSone : getLocalSones()) {
+ for (LocalSone localSone : getLocalSones()) {
if (localSone.getOptions().isAutoFollow()) {
followSone(localSone, sone.getId());
}
* @param soneId
* The ID of the Sone to follow
*/
- public void followSone(Sone sone, String soneId) {
+ public void followSone(LocalSone sone, String soneId) {
checkNotNull(sone, "sone must not be null");
checkNotNull(soneId, "soneId must not be null");
database.addFriend(sone, soneId);
* @param soneId
* The ID of the Sone being unfollowed
*/
- public void unfollowSone(Sone sone, String soneId) {
+ public void unfollowSone(LocalSone sone, String soneId) {
checkNotNull(sone, "sone must not be null");
checkNotNull(soneId, "soneId must not be null");
database.removeFriend(sone, soneId);
package net.pterodactylus.sone.database;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Sone;
/**
*/
public interface FriendStore {
- void addFriend(Sone localSone, String friendSoneId);
- void removeFriend(Sone localSone, String friendSoneId);
+ void addFriend(LocalSone localSone, String friendSoneId);
+ void removeFriend(LocalSone localSone, String friendSoneId);
}
}
@Override
- public void addFriend(Sone localSone, String friendSoneId) {
- if (!localSone.isLocal()) {
- return;
- }
+ public void addFriend(LocalSone localSone, String friendSoneId) {
memoryFriendDatabase.addFriend(localSone.getId(), friendSoneId);
}
@Override
- public void removeFriend(Sone localSone, String friendSoneId) {
- if (!localSone.isLocal()) {
- return;
- }
+ public void removeFriend(LocalSone localSone, String friendSoneId) {
memoryFriendDatabase.removeFriend(localSone.getId(), friendSoneId);
}
import com.google.common.base.Optional;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
super.processTemplate(request, templateContext);
if (request.getMethod() == Method.POST) {
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
- Sone currentSone = getCurrentSone(request.getToadletContext()).get();
+ LocalSone currentSone = getCurrentSone(request.getToadletContext()).get();
String soneIds = request.getHttpRequest().getPartAsStringFailsafe("sone", 1200);
for (String soneId : soneIds.split("[ ,]+")) {
Optional<Sone> sone = webInterface.getCore().getSone(soneId);
package net.pterodactylus.sone.web;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
super.processTemplate(request, templateContext);
if (request.getMethod() == Method.POST) {
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
- Sone currentSone = getCurrentSone(request.getToadletContext()).get();
+ LocalSone currentSone = getCurrentSone(request.getToadletContext()).get();
String soneIds = request.getHttpRequest().getPartAsStringFailsafe("sone", 2000);
for (String soneId : soneIds.split("[ ,]+")) {
webInterface.getCore().unfollowSone(currentSone, soneId);
import com.google.common.base.Optional;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
if (!sone.isPresent()) {
return createErrorJsonObject("invalid-sone-id");
}
- Sone currentSone = getCurrentSone(request.getToadletContext()).get();
+ LocalSone currentSone = getCurrentSone(request.getToadletContext()).get();
webInterface.getCore().followSone(currentSone, soneId);
webInterface.getCore().markSoneKnown(sone.get());
return createSuccessJsonObject();
package net.pterodactylus.sone.web.ajax;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
if (!webInterface.getCore().getSone(soneId).isPresent()) {
return createErrorJsonObject("invalid-sone-id");
}
- Sone currentSone = getCurrentSone(request.getToadletContext()).get();
+ LocalSone currentSone = getCurrentSone(request.getToadletContext()).get();
if (currentSone == null) {
return createErrorJsonObject("auth-required");
}