projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move unliking a post from Sone to Post.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
web
/
ajax
/
UnlikeAjaxPage.java
diff --git
a/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java
b/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java
index
bd3c387
..
5ac0ca0
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java
@@
-22,6
+22,8
@@
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
+import com.google.common.base.Optional;
+
/**
* AJAX page that lets the user unlike a {@link Post}.
*
/**
* AJAX page that lets the user unlike a {@link Post}.
*
@@
-51,7
+53,10
@@
public class UnlikeAjaxPage extends JsonPage {
return createErrorJsonObject("auth-required");
}
if ("post".equals(type)) {
return createErrorJsonObject("auth-required");
}
if ("post".equals(type)) {
- currentSone.removeLikedPostId(id);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(id);
+ if (post.isPresent()) {
+ post.get().unlike(currentSone);
+ }
webInterface.getCore().touchConfiguration();
} else if ("reply".equals(type)) {
currentSone.removeLikedReplyId(id);
webInterface.getCore().touchConfiguration();
} else if ("reply".equals(type)) {
currentSone.removeLikedReplyId(id);