add: purge/restore post api

This commit is contained in:
trisua 2025-05-16 16:20:24 -04:00
parent 81307752c2
commit dd4f8b6d58
6 changed files with 102 additions and 4 deletions

View file

@ -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", {