commit 8fe7645
Merge pull request 'add support for Subway Tooter app' (#111) from pswilde/snac2:master into master Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/111
2 files changed,
+31,
-0
M
httpd.c
M
httpd.c
+8,
-0
1@@ -223,6 +223,14 @@ int server_get_handler(xs_dict *req, const char *q_path,
2 srv_baseurl);
3 }
4 else
5+ if (strcmp(q_path, "/.well-known/host-meta") == 0) {
6+ status = 200;
7+ *ctype = "application/xrd+xml";
8+ *body = xs_str_new("<XRD>"
9+ "<Link rel=\"lrdd\" type=\"application/xrd+xml\" template=\"%s/.well-known/webfinger?resource={uri}\"/>"
10+ "</XRD>");
11+ }
12+ else
13 if (strcmp(q_path, "/nodeinfo_2_0") == 0) {
14 status = 200;
15 *ctype = "application/json; charset=utf-8";
+23,
-0
1@@ -359,6 +359,12 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
2 }
3 }
4
5+ /* no code?
6+ I'm not sure of the impacts of this right now, but Subway Tooter does not
7+ provide a code so one must be generated */
8+ if (xs_is_null(code)){
9+ code = random_str();
10+ }
11 if (gtype && code && cid && csec && ruri) {
12 xs *app = app_get(cid);
13
14@@ -1622,6 +1628,15 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
15 status = 200;
16 }
17 else
18+ if (strcmp(cmd, "/v2/filters") == 0) { /** **/
19+ /* snac will never have filters
20+ * but still, without a v2 endpoint a short delay is introduced
21+ * in some apps */
22+ *body = xs_dup("[]");
23+ *ctype = "application/json";
24+ status = 200;
25+ }
26+ else
27 if (strcmp(cmd, "/v1/favourites") == 0) { /** **/
28 /* snac will never support a list of favourites */
29 *body = xs_dup("[]");
30@@ -1990,6 +2005,14 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
31 if (!xs_is_null(payload))
32 args = xs_json_loads(payload);
33 }
34+ else if (i_ctype && xs_startswith(i_ctype, "application/x-www-form-urlencoded"))
35+ {
36+ // Some apps send form data instead of json so we should cater for those
37+ if (!xs_is_null(payload)) {
38+ xs *upl = xs_url_dec(payload);
39+ args = xs_url_vars(upl);
40+ }
41+ }
42 else
43 args = xs_dup(xs_dict_get(req, "p_vars"));
44