summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrunfink <grunfink@noreply.codeberg.org>2024-01-29 08:37:52 +0000
committergrunfink <grunfink@noreply.codeberg.org>2024-01-29 08:37:52 +0000
commit8fe76454d322ef26489b075e43a02af1ce7f8424 (patch)
treec07e3d4badfed27fb6ac4f8a23687ec435300092
parentd839654ccbea5c9d9f9b01d9669a48bf6e42b56f (diff)
parentd7978621ed3756dd3d021631d7f735ef0d8f39d4 (diff)
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
-rw-r--r--httpd.c8
-rw-r--r--mastoapi.c23
2 files changed, 31 insertions, 0 deletions
diff --git a/httpd.c b/httpd.c
index 0bdd9bc..a20d692 100644
--- a/httpd.c
+++ b/httpd.c
@@ -223,6 +223,14 @@ int server_get_handler(xs_dict *req, const char *q_path,
srv_baseurl);
}
else
+ if (strcmp(q_path, "/.well-known/host-meta") == 0) {
+ status = 200;
+ *ctype = "application/xrd+xml";
+ *body = xs_str_new("<XRD>"
+ "<Link rel=\"lrdd\" type=\"application/xrd+xml\" template=\"%s/.well-known/webfinger?resource={uri}\"/>"
+ "</XRD>");
+ }
+ else
if (strcmp(q_path, "/nodeinfo_2_0") == 0) {
status = 200;
*ctype = "application/json; charset=utf-8";
diff --git a/mastoapi.c b/mastoapi.c
index d8ec3b3..efcdae8 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -359,6 +359,12 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
}
}
+ /* no code?
+ I'm not sure of the impacts of this right now, but Subway Tooter does not
+ provide a code so one must be generated */
+ if (xs_is_null(code)){
+ code = random_str();
+ }
if (gtype && code && cid && csec && ruri) {
xs *app = app_get(cid);
@@ -1622,6 +1628,15 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
status = 200;
}
else
+ if (strcmp(cmd, "/v2/filters") == 0) { /** **/
+ /* snac will never have filters
+ * but still, without a v2 endpoint a short delay is introduced
+ * in some apps */
+ *body = xs_dup("[]");
+ *ctype = "application/json";
+ status = 200;
+ }
+ else
if (strcmp(cmd, "/v1/favourites") == 0) { /** **/
/* snac will never support a list of favourites */
*body = xs_dup("[]");
@@ -1990,6 +2005,14 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
if (!xs_is_null(payload))
args = xs_json_loads(payload);
}
+ else if (i_ctype && xs_startswith(i_ctype, "application/x-www-form-urlencoded"))
+ {
+ // Some apps send form data instead of json so we should cater for those
+ if (!xs_is_null(payload)) {
+ xs *upl = xs_url_dec(payload);
+ args = xs_url_vars(upl);
+ }
+ }
else
args = xs_dup(xs_dict_get(req, "p_vars"));