summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorGravatar James Seward2024-01-11 13:38:08 +0000
committerGravatar James Seward2024-01-11 13:38:08 +0000
commitc3fb6bab77f35be6cda261f257b8731d38e5265f (patch)
tree683be057b3f1b659648e0fdecaca59955fc785ab /mastoapi.c
parentAdd missing fields to account verification (diff)
downloadsnac2-c3fb6bab77f35be6cda261f257b8731d38e5265f.tar.gz
snac2-c3fb6bab77f35be6cda261f257b8731d38e5265f.tar.xz
snac2-c3fb6bab77f35be6cda261f257b8731d38e5265f.zip
Support DELETE for Mastodon subscriptions
While testing Mona, I noticed that after deleting my account entry for my snac server, Mona would repeatedly try to delete the subscription it thought it had created, resulting in many unhandled DELETE calls. This accepts the call and returns 200 for it, which makes Mona happy.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 5c89172..c1a889d 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -2484,6 +2484,22 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
2484} 2484}
2485 2485
2486 2486
2487int 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
2487int mastoapi_put_handler(const xs_dict *req, const char *q_path, 2503int 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)