diff options
Diffstat (limited to '')
| -rw-r--r-- | httpd.c | 8 | ||||
| -rw-r--r-- | mastoapi.c | 16 | ||||
| -rw-r--r-- | snac.h | 2 |
3 files changed, 26 insertions, 0 deletions
| @@ -344,6 +344,14 @@ void httpd_connection(FILE *f) | |||
| 344 | if (strcmp(method, "OPTIONS") == 0) { | 344 | if (strcmp(method, "OPTIONS") == 0) { |
| 345 | status = 200; | 345 | status = 200; |
| 346 | } | 346 | } |
| 347 | else | ||
| 348 | if (strcmp(method, "DELETE") == 0) { | ||
| 349 | #ifndef NO_MASTODON_API | ||
| 350 | if (status == 0) | ||
| 351 | status = mastoapi_delete_handler(req, q_path, | ||
| 352 | &body, &b_size, &ctype); | ||
| 353 | #endif | ||
| 354 | } | ||
| 347 | 355 | ||
| 348 | /* unattended? it's an error */ | 356 | /* unattended? it's an error */ |
| 349 | if (status == 0) { | 357 | if (status == 0) { |
| @@ -2484,6 +2484,22 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2484 | } | 2484 | } |
| 2485 | 2485 | ||
| 2486 | 2486 | ||
| 2487 | int mastoapi_delete_handler(const xs_dict *req, const char *q_path, | ||
| 2488 | char **body, int *b_size, char **ctype) { | ||
| 2489 | |||
| 2490 | if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) | ||
| 2491 | return 0; | ||
| 2492 | |||
| 2493 | srv_debug(1, xs_fmt("mastoapi_delete_handler %s", q_path)); | ||
| 2494 | xs *cmd = xs_replace_n(q_path, "/api", "", 1); | ||
| 2495 | if (xs_startswith(cmd, "/v1/push/subscription") || xs_startswith(cmd, "/v2/push/subscription")) { /** **/ | ||
| 2496 | // pretend we deleted it, since it doesn't exist anyway | ||
| 2497 | return 200; | ||
| 2498 | } | ||
| 2499 | return 0; | ||
| 2500 | } | ||
| 2501 | |||
| 2502 | |||
| 2487 | int mastoapi_put_handler(const xs_dict *req, const char *q_path, | 2503 | int mastoapi_put_handler(const xs_dict *req, const char *q_path, |
| 2488 | const char *payload, int p_size, | 2504 | const char *payload, int p_size, |
| 2489 | char **body, int *b_size, char **ctype) | 2505 | char **body, int *b_size, char **ctype) |
| @@ -312,6 +312,8 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 312 | char **body, int *b_size, char **ctype); | 312 | char **body, int *b_size, char **ctype); |
| 313 | int mastoapi_get_handler(const xs_dict *req, const char *q_path, | 313 | int mastoapi_get_handler(const xs_dict *req, const char *q_path, |
| 314 | char **body, int *b_size, char **ctype); | 314 | char **body, int *b_size, char **ctype); |
| 315 | int mastoapi_delete_handler(const xs_dict *req, const char *q_path, | ||
| 316 | char **body, int *b_size, char **ctype); | ||
| 315 | int mastoapi_post_handler(const xs_dict *req, const char *q_path, | 317 | int mastoapi_post_handler(const xs_dict *req, const char *q_path, |
| 316 | const char *payload, int p_size, | 318 | const char *payload, int p_size, |
| 317 | char **body, int *b_size, char **ctype); | 319 | char **body, int *b_size, char **ctype); |