commit 285fb58
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
3 files changed,
+31,
-0
M
httpd.c
+8,
-0
1@@ -344,6 +344,14 @@ void httpd_connection(FILE *f)
2 if (strcmp(method, "OPTIONS") == 0) {
3 status = 200;
4 }
5+ else
6+ if (strcmp(method, "DELETE") == 0) {
7+#ifndef NO_MASTODON_API
8+ if (status == 0)
9+ status = mastoapi_delete_handler(req, q_path,
10+ &body, &b_size, &ctype);
11+#endif
12+ }
13
14 /* unattended? it's an error */
15 if (status == 0) {
+21,
-0
1@@ -1118,9 +1118,14 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2 acct = xs_dict_append(acct, "acct", xs_dict_get(snac1.config, "uid"));
3 acct = xs_dict_append(acct, "display_name", xs_dict_get(snac1.config, "name"));
4 acct = xs_dict_append(acct, "created_at", xs_dict_get(snac1.config, "published"));
5+ acct = xs_dict_append(acct, "last_status_at", xs_dict_get(snac1.config, "published"));
6 acct = xs_dict_append(acct, "note", xs_dict_get(snac1.config, "bio"));
7 acct = xs_dict_append(acct, "url", snac1.actor);
8 acct = xs_dict_append(acct, "header", "");
9+ acct = xs_dict_append(acct, "header_static", "");
10+ acct = xs_dict_append(acct, "locked", xs_stock_false);
11+ // FIXME: check value of "type" to set this correctly?
12+ acct = xs_dict_append(acct, "bot", xs_stock_false);
13
14 xs *src = xs_json_loads("{\"privacy\":\"public\","
15 "\"sensitive\":false,\"fields\":[],\"note\":\"\"}");
16@@ -2479,6 +2484,22 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
17 }
18
19
20+int mastoapi_delete_handler(const xs_dict *req, const char *q_path,
21+ char **body, int *b_size, char **ctype) {
22+
23+ if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/"))
24+ return 0;
25+
26+ srv_debug(1, xs_fmt("mastoapi_delete_handler %s", q_path));
27+ xs *cmd = xs_replace_n(q_path, "/api", "", 1);
28+ if (xs_startswith(cmd, "/v1/push/subscription") || xs_startswith(cmd, "/v2/push/subscription")) { /** **/
29+ // pretend we deleted it, since it doesn't exist anyway
30+ return 200;
31+ }
32+ return 0;
33+}
34+
35+
36 int mastoapi_put_handler(const xs_dict *req, const char *q_path,
37 const char *payload, int p_size,
38 char **body, int *b_size, char **ctype)
M
snac.h
+2,
-0
1@@ -312,6 +312,8 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
2 char **body, int *b_size, char **ctype);
3 int mastoapi_get_handler(const xs_dict *req, const char *q_path,
4 char **body, int *b_size, char **ctype);
5+int mastoapi_delete_handler(const xs_dict *req, const char *q_path,
6+ char **body, int *b_size, char **ctype);
7 int mastoapi_post_handler(const xs_dict *req, const char *q_path,
8 const char *payload, int p_size,
9 char **body, int *b_size, char **ctype);