summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorGravatar Paul Wilde2024-01-28 20:55:43 +0000
committerGravatar Paul Wilde2024-01-28 20:55:43 +0000
commit253e627ee067b1f2504dd11c7934ce51b0a2f5b2 (patch)
tree9b682a0bbd378db42e30868d2967a0192f88e3dd /mastoapi.c
parentMerge remote-tracking branch 'upstream/master' (diff)
downloadpenes-snac2-253e627ee067b1f2504dd11c7934ce51b0a2f5b2.tar.gz
penes-snac2-253e627ee067b1f2504dd11c7934ce51b0a2f5b2.tar.xz
penes-snac2-253e627ee067b1f2504dd11c7934ce51b0a2f5b2.zip
make compatible with subway tooter app
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/mastoapi.c b/mastoapi.c
index d8ec3b3..6ed3835 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
@@ -1408,7 +1414,6 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1408 const char *type = xs_dict_get(msg, "type"); 1414 const char *type = xs_dict_get(msg, "type");
1409 if (!xs_match(type, "Note|Question|Page|Article")) 1415 if (!xs_match(type, "Note|Question|Page|Article"))
1410 continue; 1416 continue;
1411
1412 const char *from = NULL; 1417 const char *from = NULL;
1413 if (strcmp(type, "Page") == 0) 1418 if (strcmp(type, "Page") == 0)
1414 from = xs_dict_get(msg, "audience"); 1419 from = xs_dict_get(msg, "audience");
@@ -1622,6 +1627,15 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1622 status = 200; 1627 status = 200;
1623 } 1628 }
1624 else 1629 else
1630 if (strcmp(cmd, "/v2/filters") == 0) { /** **/
1631 /* snac will never have filters
1632 * but still, without a v2 endpoint a short delay is introduced
1633 * in some apps */
1634 *body = xs_dup("[]");
1635 *ctype = "application/json";
1636 status = 200;
1637 }
1638 else
1625 if (strcmp(cmd, "/v1/favourites") == 0) { /** **/ 1639 if (strcmp(cmd, "/v1/favourites") == 0) { /** **/
1626 /* snac will never support a list of favourites */ 1640 /* snac will never support a list of favourites */
1627 *body = xs_dup("[]"); 1641 *body = xs_dup("[]");
@@ -1990,6 +2004,14 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
1990 if (!xs_is_null(payload)) 2004 if (!xs_is_null(payload))
1991 args = xs_json_loads(payload); 2005 args = xs_json_loads(payload);
1992 } 2006 }
2007 else if (i_ctype && xs_startswith(i_ctype, "application/x-www-form-urlencoded"))
2008 {
2009 // Some apps send form data instead of json so we should cater for those
2010 if (!xs_is_null(payload)) {
2011 xs *upl = xs_url_dec(payload);
2012 args = xs_url_vars(upl);
2013 }
2014 }
1993 else 2015 else
1994 args = xs_dup(xs_dict_get(req, "p_vars")); 2016 args = xs_dup(xs_dict_get(req, "p_vars"));
1995 2017