projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
858555f
)
Use local Sones in more places where it’s appropriate.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Fri, 5 Dec 2014 21:13:47 +0000
(22:13 +0100)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Fri, 5 Dec 2014 21:13:47 +0000
(22:13 +0100)
src/main/java/net/pterodactylus/sone/core/Core.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/database/FriendStore.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/FollowSonePage.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/UnfollowSonePage.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/core/Core.java
b/src/main/java/net/pterodactylus/sone/core/Core.java
index
90b6e2e
..
6ca7372
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/core/Core.java
+++ b/
src/main/java/net/pterodactylus/sone/core/Core.java
@@
-605,7
+605,7
@@
public class Core extends AbstractService implements SoneProvider, PostProvider,
* The own identity to create a Sone from
* @return The added (or already existing) Sone
*/
* The own identity to create a Sone from
* @return The added (or already existing) Sone
*/
- public Sone addLocalSone(OwnIdentity ownIdentity) {
+ public
Local
Sone addLocalSone(OwnIdentity ownIdentity) {
if (ownIdentity == null) {
logger.log(Level.WARNING, "Given OwnIdentity is null!");
return null;
if (ownIdentity == null) {
logger.log(Level.WARNING, "Given OwnIdentity is null!");
return null;
@@
-637,7
+637,7
@@
public class Core extends AbstractService implements SoneProvider, PostProvider,
logger.log(Level.SEVERE, String.format("Could not add “Sone” context to own identity: %s", ownIdentity));
return null;
}
logger.log(Level.SEVERE, String.format("Could not add “Sone” context to own identity: %s", ownIdentity));
return null;
}
- Sone sone = addLocalSone(ownIdentity);
+
Local
Sone sone = addLocalSone(ownIdentity);
followSone(sone, "nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI");
touchConfiguration();
followSone(sone, "nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI");
touchConfiguration();
@@
-670,7
+670,7
@@
public class Core extends AbstractService implements SoneProvider, PostProvider,
sone.setKnown(!newSone);
if (newSone) {
eventBus.post(new NewSoneFoundEvent(sone));
sone.setKnown(!newSone);
if (newSone) {
eventBus.post(new NewSoneFoundEvent(sone));
- for (Sone localSone : getLocalSones()) {
+ for (
Local
Sone localSone : getLocalSones()) {
if (localSone.getOptions().isAutoFollow()) {
followSone(localSone, sone.getId());
}
if (localSone.getOptions().isAutoFollow()) {
followSone(localSone, sone.getId());
}
@@
-691,7
+691,7
@@
public class Core extends AbstractService implements SoneProvider, PostProvider,
* @param soneId
* The ID of the Sone to follow
*/
* @param soneId
* The ID of the Sone to follow
*/
- public void followSone(Sone sone, String soneId) {
+ public void followSone(
Local
Sone sone, String soneId) {
checkNotNull(sone, "sone must not be null");
checkNotNull(soneId, "soneId must not be null");
database.addFriend(sone, soneId);
checkNotNull(sone, "sone must not be null");
checkNotNull(soneId, "soneId must not be null");
database.addFriend(sone, soneId);
@@
-726,7
+726,7
@@
public class Core extends AbstractService implements SoneProvider, PostProvider,
* @param soneId
* The ID of the Sone being unfollowed
*/
* @param soneId
* The ID of the Sone being unfollowed
*/
- public void unfollowSone(Sone sone, String soneId) {
+ public void unfollowSone(
Local
Sone sone, String soneId) {
checkNotNull(sone, "sone must not be null");
checkNotNull(soneId, "soneId must not be null");
database.removeFriend(sone, soneId);
checkNotNull(sone, "sone must not be null");
checkNotNull(soneId, "soneId must not be null");
database.removeFriend(sone, soneId);
diff --git
a/src/main/java/net/pterodactylus/sone/database/FriendStore.java
b/src/main/java/net/pterodactylus/sone/database/FriendStore.java
index
38c1c80
..
b00550f
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/database/FriendStore.java
+++ b/
src/main/java/net/pterodactylus/sone/database/FriendStore.java
@@
-1,5
+1,6
@@
package net.pterodactylus.sone.database;
package net.pterodactylus.sone.database;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Sone;
/**
import net.pterodactylus.sone.data.Sone;
/**
@@
-9,7
+10,7
@@
import net.pterodactylus.sone.data.Sone;
*/
public interface FriendStore {
*/
public interface FriendStore {
- void addFriend(Sone localSone, String friendSoneId);
- void removeFriend(Sone localSone, String friendSoneId);
+ void addFriend(
Local
Sone localSone, String friendSoneId);
+ void removeFriend(
Local
Sone localSone, String friendSoneId);
}
}
diff --git
a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java
b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java
index
bfea5e2
..
983f8da
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java
+++ b/
src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java
@@
-640,18
+640,12
@@
public class MemoryDatabase extends AbstractService implements Database {
}
@Override
}
@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
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);
}
memoryFriendDatabase.removeFriend(localSone.getId(), friendSoneId);
}
diff --git
a/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java
b/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java
index
ca29fc9
..
8428630
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/FollowSonePage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/FollowSonePage.java
@@
-19,6
+19,7
@@
package net.pterodactylus.sone.web;
import com.google.common.base.Optional;
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;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
@@
-54,7
+55,7
@@
public class FollowSonePage extends SoneTemplatePage {
super.processTemplate(request, templateContext);
if (request.getMethod() == Method.POST) {
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
super.processTemplate(request, templateContext);
if (request.getMethod() == Method.POST) {
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
- Sone currentSone = getCurrentSone(request.getToadletContext()).get();
+
Local
Sone currentSone = getCurrentSone(request.getToadletContext()).get();
String soneIds = request.getHttpRequest().getPartAsStringFailsafe("sone", 1200);
for (String soneId : soneIds.split("[ ,]+")) {
Optional<Sone> sone = webInterface.getCore().getSone(soneId);
String soneIds = request.getHttpRequest().getPartAsStringFailsafe("sone", 1200);
for (String soneId : soneIds.split("[ ,]+")) {
Optional<Sone> sone = webInterface.getCore().getSone(soneId);
diff --git
a/src/main/java/net/pterodactylus/sone/web/UnfollowSonePage.java
b/src/main/java/net/pterodactylus/sone/web/UnfollowSonePage.java
index
bddfe23
..
c6e350c
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/UnfollowSonePage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/UnfollowSonePage.java
@@
-17,6
+17,7
@@
package net.pterodactylus.sone.web;
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;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
@@
-52,7
+53,7
@@
public class UnfollowSonePage extends SoneTemplatePage {
super.processTemplate(request, templateContext);
if (request.getMethod() == Method.POST) {
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
super.processTemplate(request, templateContext);
if (request.getMethod() == Method.POST) {
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
- Sone currentSone = getCurrentSone(request.getToadletContext()).get();
+
Local
Sone currentSone = getCurrentSone(request.getToadletContext()).get();
String soneIds = request.getHttpRequest().getPartAsStringFailsafe("sone", 2000);
for (String soneId : soneIds.split("[ ,]+")) {
webInterface.getCore().unfollowSone(currentSone, soneId);
String soneIds = request.getHttpRequest().getPartAsStringFailsafe("sone", 2000);
for (String soneId : soneIds.split("[ ,]+")) {
webInterface.getCore().unfollowSone(currentSone, soneId);
diff --git
a/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java
b/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java
index
3b51df2
..
c394326
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java
@@
-19,6
+19,7
@@
package net.pterodactylus.sone.web.ajax;
import com.google.common.base.Optional;
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;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
@@
-50,7
+51,7
@@
public class FollowSoneAjaxPage extends JsonPage {
if (!sone.isPresent()) {
return createErrorJsonObject("invalid-sone-id");
}
if (!sone.isPresent()) {
return createErrorJsonObject("invalid-sone-id");
}
- Sone currentSone = getCurrentSone(request.getToadletContext()).get();
+
Local
Sone currentSone = getCurrentSone(request.getToadletContext()).get();
webInterface.getCore().followSone(currentSone, soneId);
webInterface.getCore().markSoneKnown(sone.get());
return createSuccessJsonObject();
webInterface.getCore().followSone(currentSone, soneId);
webInterface.getCore().markSoneKnown(sone.get());
return createSuccessJsonObject();
diff --git
a/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java
b/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java
index
1e87b15
..
e5fc749
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java
@@
-17,6
+17,7
@@
package net.pterodactylus.sone.web.ajax;
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;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
@@
-47,7
+48,7
@@
public class UnfollowSoneAjaxPage extends JsonPage {
if (!webInterface.getCore().getSone(soneId).isPresent()) {
return createErrorJsonObject("invalid-sone-id");
}
if (!webInterface.getCore().getSone(soneId).isPresent()) {
return createErrorJsonObject("invalid-sone-id");
}
- Sone currentSone = getCurrentSone(request.getToadletContext()).get();
+
Local
Sone currentSone = getCurrentSone(request.getToadletContext()).get();
if (currentSone == null) {
return createErrorJsonObject("auth-required");
}
if (currentSone == null) {
return createErrorJsonObject("auth-required");
}