package net.pterodactylus.sone.web;
import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.Page.Request.Method;
import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.Template;
String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
Post post = webInterface.getCore().getPost(postId);
- Sone currentSone = getCurrentSone(request.getToadletContext());
- if (!post.getSone().equals(currentSone)) {
+ if (!webInterface.getCore().isLocalSone(post.getSone())) {
throw new RedirectException("noPermission.html");
}
if (request.getHttpRequest().isPartSet("confirmDelete")) {
- currentSone.removePost(post);
+ webInterface.getCore().deletePost(post);
throw new RedirectException(returnPage);
} else if (request.getHttpRequest().isPartSet("abortDelete")) {
throw new RedirectException(returnPage);
package net.pterodactylus.sone.web.ajax;
import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.util.json.JsonObject;
protected JsonObject createJsonObject(Request request) {
String postId = request.getHttpRequest().getParam("post");
Post post = webInterface.getCore().getPost(postId, false);
- Sone currentSone = getCurrentSone(request.getToadletContext());
if ((post == null) || (post.getSone() == null)) {
return createErrorJsonObject("invalid-post-id");
}
- if (currentSone == null) {
- return createErrorJsonObject("auth-required");
- }
- if (!post.getSone().equals(currentSone)) {
+ if (!webInterface.getCore().isLocalSone(post.getSone())) {
return createErrorJsonObject("not-authorized");
}
webInterface.getCore().deletePost(post);
</form>
<%/if>
<%/if>
- <%if post.sone.current>
+ <%if post.sone.local>
<span class='separator'>·</span>
<form class="delete delete-post" action="deletePost.html" method="post">
<input type="hidden" name="formPassword" value="<% formPassword|html>" />
</form>
<%/if>
<%/if>
- <%if reply.sone.current>
+ <%if reply.sone.local>
<span class='separator'>·</span>
<form class="delete delete-reply" action="deleteReply.html" method="post">
<input type="hidden" name="formPassword" value="<% formPassword|html>" />