add: purge/restore post api
This commit is contained in:
parent
81307752c2
commit
dd4f8b6d58
6 changed files with 102 additions and 4 deletions
|
@ -382,6 +382,7 @@ and show_community and community.id != config.town_square or question %}
|
|||
>
|
||||
</a>
|
||||
|
||||
{% if not post.is_deleted %}
|
||||
<button
|
||||
class="red"
|
||||
onclick="trigger('me::remove_post', ['{{ post.id }}'])"
|
||||
|
@ -389,7 +390,23 @@ and show_community and community.id != config.town_square or question %}
|
|||
{{ icon "trash" }}
|
||||
<span>{{ text "general:action.delete" }}</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% endif %} {% if is_helper and post.is_deleted %}
|
||||
<button
|
||||
class="red"
|
||||
onclick="trigger('me::purge_post', ['{{ post.id }}'])"
|
||||
>
|
||||
{{ icon "trash-2" }}
|
||||
<span>{{ text "general:action.purge" }}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="green"
|
||||
onclick="trigger('me::restore_post', ['{{ post.id }}'])"
|
||||
>
|
||||
{{ icon "undo" }}
|
||||
<span>{{ text "general:action.restore" }}</span>
|
||||
</button>
|
||||
{% endif %} {% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -62,6 +62,48 @@
|
|||
});
|
||||
});
|
||||
|
||||
self.define("purge_post", async (_, id) => {
|
||||
if (
|
||||
!(await trigger("atto::confirm", [
|
||||
"Are you sure you want to do this? This cannot be undone.",
|
||||
]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/v1/posts/${id}/purge`, {
|
||||
method: "DELETE",
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
self.define("restore_post", async (_, id) => {
|
||||
if (
|
||||
!(await trigger("atto::confirm", [
|
||||
"Are you sure you want to do this?",
|
||||
]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/v1/posts/${id}/restore`, {
|
||||
method: "POST",
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
self.define("react", async (_, element, asset, asset_type, is_like) => {
|
||||
await trigger("atto::debounce", ["reactions::toggle"]);
|
||||
fetch("/api/v1/reactions", {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue