aboutsummaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorgrunfink <grunfink@comam.es>2025-10-10 21:17:54 +0200
committergrunfink <grunfink@comam.es>2025-10-10 21:17:54 +0200
commit885ee3f5b9b9b9c1bac46bfd72af613230067e08 (patch)
tree1399a0f3fb611a05e682286d8045077478597161 /mastoapi.c
parent7d942d42df5e58e67ea9bbf3cfc92ec23a7f929d (diff)
mastoapi: added deleting for posts.
I'm sure that I've done this before, but whatever.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 26af7d2..c526307 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -3462,7 +3462,6 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path,
char **body, int *b_size, char **ctype)
{
(void)p_size;
- (void)body;
(void)b_size;
(void)ctype;
@@ -3535,6 +3534,41 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path,
else
status = HTTP_STATUS_UNAUTHORIZED;
}
+ else
+ if (xs_startswith(cmd, "/v1/statuses/")) {
+ if (logged_in) {
+ xs *l = xs_split(cmd, "/");
+ const char *p = xs_list_get(l, -1);
+ p = MID_TO_MD5(p);
+
+ xs *obj = NULL;
+ if (valid_status(object_get_by_md5(p, &obj))) {
+ const char *id = xs_dict_get(obj, "id");
+
+ if (xs_is_string(id) && xs_startswith(id, snac.actor)) {
+ xs *out = mastoapi_status(&snac, obj);
+
+ xs *msg = msg_delete(&snac, id);
+
+ enqueue_message(&snac, msg);
+
+ timeline_del(&snac, id);
+
+ draft_del(&snac, id);
+
+ schedule_del(&snac, id);
+
+ snac_log(&snac, xs_fmt("deleted entry %s", id));
+
+ *body = xs_json_dumps(out, 4);
+ *ctype = "application/json";
+ status = HTTP_STATUS_OK;
+ }
+ }
+ }
+ else
+ status = HTTP_STATUS_UNAUTHORIZED;
+ }
/* user cleanup */
if (logged_in)