projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace edit album page with Kotlin version
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
web
/
ajax
/
DeletePostAjaxPage.java
diff --git
a/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java
b/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java
index
8d3b414
..
cfc1415
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java
@@
-1,5
+1,5
@@
/*
/*
- * Sone - DeletePostAjaxPage.java - Copyright © 2010 David Roden
+ * Sone - DeletePostAjaxPage.java - Copyright © 2010
–2016
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
*
* 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
@@
-17,9
+17,11
@@
package net.pterodactylus.sone.web.ajax;
package net.pterodactylus.sone.web.ajax;
+import com.google.common.base.Optional;
+
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.web.WebInterface;
-import net.pterodactylus.
util.json.JsonObjec
t;
+import net.pterodactylus.
sone.web.page.FreenetReques
t;
/**
* This AJAX page deletes a post.
/**
* This AJAX page deletes a post.
@@
-46,16
+48,16
@@
public class DeletePostAjaxPage extends JsonPage {
* {@inheritDoc}
*/
@Override
* {@inheritDoc}
*/
@Override
- protected Json
Object createJsonObject(
Request request) {
+ protected Json
ReturnObject createJsonObject(Freenet
Request request) {
String postId = request.getHttpRequest().getParam("post");
String postId = request.getHttpRequest().getParam("post");
-
Post post = webInterface.getCore().getPost(postId, false
);
- if (
(post == null) || (post.getSone() == null
)) {
+
Optional<Post> post = webInterface.getCore().getPost(postId
);
+ if (
!post.isPresent(
)) {
return createErrorJsonObject("invalid-post-id");
}
return createErrorJsonObject("invalid-post-id");
}
- if (!
webInterface.getCore().isLocalSone(post.getSone()
)) {
+ if (!
post.get().getSone().isLocal(
)) {
return createErrorJsonObject("not-authorized");
}
return createErrorJsonObject("not-authorized");
}
- webInterface.getCore().deletePost(post);
+ webInterface.getCore().deletePost(post
.get()
);
return createSuccessJsonObject();
}
return createSuccessJsonObject();
}