diff options
author | grunfink <grunfink@noreply.codeberg.org> | 2024-01-11 17:46:15 +0000 |
---|---|---|
committer | grunfink <grunfink@noreply.codeberg.org> | 2024-01-11 17:46:15 +0000 |
commit | 285fb589ff1727e61144f17f77cf275c3a5905ce (patch) | |
tree | 683be057b3f1b659648e0fdecaca59955fc785ab | |
parent | 32ce4b065911ef73f584691506698a1b1d6de23a (diff) | |
parent | c3fb6bab77f35be6cda261f257b8731d38e5265f (diff) |
Merge pull request 'Improve support for Mona iOS app' (#100) from jamesoff/snac2:monaapp-support into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/100
-rw-r--r-- | httpd.c | 8 | ||||
-rw-r--r-- | mastoapi.c | 21 | ||||
-rw-r--r-- | snac.h | 2 |
3 files changed, 31 insertions, 0 deletions
@@ -344,6 +344,14 @@ void httpd_connection(FILE *f) if (strcmp(method, "OPTIONS") == 0) { status = 200; } + else + if (strcmp(method, "DELETE") == 0) { +#ifndef NO_MASTODON_API + if (status == 0) + status = mastoapi_delete_handler(req, q_path, + &body, &b_size, &ctype); +#endif + } /* unattended? it's an error */ if (status == 0) { @@ -1118,9 +1118,14 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, acct = xs_dict_append(acct, "acct", xs_dict_get(snac1.config, "uid")); acct = xs_dict_append(acct, "display_name", xs_dict_get(snac1.config, "name")); acct = xs_dict_append(acct, "created_at", xs_dict_get(snac1.config, "published")); + acct = xs_dict_append(acct, "last_status_at", xs_dict_get(snac1.config, "published")); acct = xs_dict_append(acct, "note", xs_dict_get(snac1.config, "bio")); acct = xs_dict_append(acct, "url", snac1.actor); acct = xs_dict_append(acct, "header", ""); + acct = xs_dict_append(acct, "header_static", ""); + acct = xs_dict_append(acct, "locked", xs_stock_false); + // FIXME: check value of "type" to set this correctly? + acct = xs_dict_append(acct, "bot", xs_stock_false); xs *src = xs_json_loads("{\"privacy\":\"public\"," "\"sensitive\":false,\"fields\":[],\"note\":\"\"}"); @@ -2479,6 +2484,22 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, } +int mastoapi_delete_handler(const xs_dict *req, const char *q_path, + char **body, int *b_size, char **ctype) { + + if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) + return 0; + + srv_debug(1, xs_fmt("mastoapi_delete_handler %s", q_path)); + xs *cmd = xs_replace_n(q_path, "/api", "", 1); + if (xs_startswith(cmd, "/v1/push/subscription") || xs_startswith(cmd, "/v2/push/subscription")) { /** **/ + // pretend we deleted it, since it doesn't exist anyway + return 200; + } + return 0; +} + + int mastoapi_put_handler(const xs_dict *req, const char *q_path, const char *payload, int p_size, char **body, int *b_size, char **ctype) @@ -312,6 +312,8 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, char **body, int *b_size, char **ctype); int mastoapi_get_handler(const xs_dict *req, const char *q_path, char **body, int *b_size, char **ctype); +int mastoapi_delete_handler(const xs_dict *req, const char *q_path, + char **body, int *b_size, char **ctype); int mastoapi_post_handler(const xs_dict *req, const char *q_path, const char *payload, int p_size, char **body, int *b_size, char **ctype); |