summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar grunfink2024-01-29 08:37:52 +0000
committerGravatar grunfink2024-01-29 08:37:52 +0000
commit8fe76454d322ef26489b075e43a02af1ce7f8424 (patch)
treec07e3d4badfed27fb6ac4f8a23687ec435300092
parentMoved the favicon link out of the CSS loop. (diff)
parentformatting (diff)
downloadsnac2-8fe76454d322ef26489b075e43a02af1ce7f8424.tar.gz
snac2-8fe76454d322ef26489b075e43a02af1ce7f8424.tar.xz
snac2-8fe76454d322ef26489b075e43a02af1ce7f8424.zip
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,
223 srv_baseurl); 223 srv_baseurl);
224 } 224 }
225 else 225 else
226 if (strcmp(q_path, "/.well-known/host-meta") == 0) {
227 status = 200;
228 *ctype = "application/xrd+xml";
229 *body = xs_str_new("<XRD>"
230 "<Link rel=\"lrdd\" type=\"application/xrd+xml\" template=\"%s/.well-known/webfinger?resource={uri}\"/>"
231 "</XRD>");
232 }
233 else
226 if (strcmp(q_path, "/nodeinfo_2_0") == 0) { 234 if (strcmp(q_path, "/nodeinfo_2_0") == 0) {
227 status = 200; 235 status = 200;
228 *ctype = "application/json; charset=utf-8"; 236 *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,
359 } 359 }
360 } 360 }
361 361
362 /* no code?
363 I'm not sure of the impacts of this right now, but Subway Tooter does not
364 provide a code so one must be generated */
365 if (xs_is_null(code)){
366 code = random_str();
367 }
362 if (gtype && code && cid && csec && ruri) { 368 if (gtype && code && cid && csec && ruri) {
363 xs *app = app_get(cid); 369 xs *app = app_get(cid);
364 370
@@ -1622,6 +1628,15 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1622 status = 200; 1628 status = 200;
1623 } 1629 }
1624 else 1630 else
1631 if (strcmp(cmd, "/v2/filters") == 0) { /** **/
1632 /* snac will never have filters
1633 * but still, without a v2 endpoint a short delay is introduced
1634 * in some apps */
1635 *body = xs_dup("[]");
1636 *ctype = "application/json";
1637 status = 200;
1638 }
1639 else
1625 if (strcmp(cmd, "/v1/favourites") == 0) { /** **/ 1640 if (strcmp(cmd, "/v1/favourites") == 0) { /** **/
1626 /* snac will never support a list of favourites */ 1641 /* snac will never support a list of favourites */
1627 *body = xs_dup("[]"); 1642 *body = xs_dup("[]");
@@ -1990,6 +2005,14 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
1990 if (!xs_is_null(payload)) 2005 if (!xs_is_null(payload))
1991 args = xs_json_loads(payload); 2006 args = xs_json_loads(payload);
1992 } 2007 }
2008 else if (i_ctype && xs_startswith(i_ctype, "application/x-www-form-urlencoded"))
2009 {
2010 // Some apps send form data instead of json so we should cater for those
2011 if (!xs_is_null(payload)) {
2012 xs *upl = xs_url_dec(payload);
2013 args = xs_url_vars(upl);
2014 }
2015 }
1993 else 2016 else
1994 args = xs_dup(xs_dict_get(req, "p_vars")); 2017 args = xs_dup(xs_dict_get(req, "p_vars"));
1995 2018