diff options
| author | 2025-10-10 21:17:54 +0200 | |
|---|---|---|
| committer | 2025-10-10 21:17:54 +0200 | |
| commit | 885ee3f5b9b9b9c1bac46bfd72af613230067e08 (patch) | |
| tree | 1399a0f3fb611a05e682286d8045077478597161 | |
| parent | Merge pull request 'fix fetching' (#479) from byte/snac2:fix/fetching into ma... (diff) | |
| download | penes-snac2-885ee3f5b9b9b9c1bac46bfd72af613230067e08.tar.gz penes-snac2-885ee3f5b9b9b9c1bac46bfd72af613230067e08.tar.xz penes-snac2-885ee3f5b9b9b9c1bac46bfd72af613230067e08.zip | |
mastoapi: added deleting for posts.
I'm sure that I've done this before, but whatever.
| -rw-r--r-- | mastoapi.c | 36 |
1 files changed, 35 insertions, 1 deletions
| @@ -3462,7 +3462,6 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path, | |||
| 3462 | char **body, int *b_size, char **ctype) | 3462 | char **body, int *b_size, char **ctype) |
| 3463 | { | 3463 | { |
| 3464 | (void)p_size; | 3464 | (void)p_size; |
| 3465 | (void)body; | ||
| 3466 | (void)b_size; | 3465 | (void)b_size; |
| 3467 | (void)ctype; | 3466 | (void)ctype; |
| 3468 | 3467 | ||
| @@ -3535,6 +3534,41 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path, | |||
| 3535 | else | 3534 | else |
| 3536 | status = HTTP_STATUS_UNAUTHORIZED; | 3535 | status = HTTP_STATUS_UNAUTHORIZED; |
| 3537 | } | 3536 | } |
| 3537 | else | ||
| 3538 | if (xs_startswith(cmd, "/v1/statuses/")) { | ||
| 3539 | if (logged_in) { | ||
| 3540 | xs *l = xs_split(cmd, "/"); | ||
| 3541 | const char *p = xs_list_get(l, -1); | ||
| 3542 | p = MID_TO_MD5(p); | ||
| 3543 | |||
| 3544 | xs *obj = NULL; | ||
| 3545 | if (valid_status(object_get_by_md5(p, &obj))) { | ||
| 3546 | const char *id = xs_dict_get(obj, "id"); | ||
| 3547 | |||
| 3548 | if (xs_is_string(id) && xs_startswith(id, snac.actor)) { | ||
| 3549 | xs *out = mastoapi_status(&snac, obj); | ||
| 3550 | |||
| 3551 | xs *msg = msg_delete(&snac, id); | ||
| 3552 | |||
| 3553 | enqueue_message(&snac, msg); | ||
| 3554 | |||
| 3555 | timeline_del(&snac, id); | ||
| 3556 | |||
| 3557 | draft_del(&snac, id); | ||
| 3558 | |||
| 3559 | schedule_del(&snac, id); | ||
| 3560 | |||
| 3561 | snac_log(&snac, xs_fmt("deleted entry %s", id)); | ||
| 3562 | |||
| 3563 | *body = xs_json_dumps(out, 4); | ||
| 3564 | *ctype = "application/json"; | ||
| 3565 | status = HTTP_STATUS_OK; | ||
| 3566 | } | ||
| 3567 | } | ||
| 3568 | } | ||
| 3569 | else | ||
| 3570 | status = HTTP_STATUS_UNAUTHORIZED; | ||
| 3571 | } | ||
| 3538 | 3572 | ||
| 3539 | /* user cleanup */ | 3573 | /* user cleanup */ |
| 3540 | if (logged_in) | 3574 | if (logged_in) |