commit 795790d
Louis Brauer
·
2024-05-30 23:22:15 +0000 UTC
parent 7e0ac64
Fix login with IceCubes and Mastodon on iOS
1 files changed,
+12,
-6
+12,
-6
1@@ -339,11 +339,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
2 const char *cid = xs_dict_get(args, "client_id");
3 const char *csec = xs_dict_get(args, "client_secret");
4 const char *ruri = xs_dict_get(args, "redirect_uri");
5- /* FIXME: this 'scope' parameter is mandatory for the official Mastodon API,
6- but if it's enabled, it makes it crash after some more steps, which
7- is FAR WORSE */
8- const char *scope = NULL;
9-// scope = xs_dict_get(args, "scope");
10+ const char *scope = xs_dict_get(args, "scope");
11
12 /* no client_secret? check if it's inside an authorization header
13 (AndStatus does it this way) */
14@@ -1165,8 +1161,10 @@ void credentials_get(char **body, char **ctype, int *status, snac snac)
15 acct = xs_dict_append(acct, "url", snac.actor);
16 acct = xs_dict_append(acct, "locked", xs_stock(XSTYPE_FALSE));
17 acct = xs_dict_append(acct, "bot", xs_dict_get(snac.config, "bot"));
18+ acct = xs_dict_append(acct, "emojis", xs_list_new());
19
20- xs *src = xs_json_loads("{\"privacy\":\"public\","
21+ xs *src = xs_json_loads("{\"privacy\":\"public\", \"language\":\"en\","
22+ "\"follow_requests_count\": 0,"
23 "\"sensitive\":false,\"fields\":[],\"note\":\"\"}");
24 /* some apps take the note from the source object */
25 src = xs_dict_set(src, "note", xs_dict_get(snac.config, "bio"));
26@@ -2379,6 +2377,14 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
27 const char *ruri = xs_dict_get(args, "redirect_uris");
28 const char *scope = xs_dict_get(args, "scope");
29
30+ /* Ice Cubes sends these values as query parameters, so try these */
31+ if (name == NULL && ruri == NULL && scope == NULL) {
32+ args = xs_dup(xs_dict_get(req, "q_vars"));
33+ name = xs_dict_get(args, "client_name");
34+ ruri = xs_dict_get(args, "redirect_uris");
35+ scope = xs_dict_get(args, "scope");
36+ }
37+
38 if (xs_type(ruri) == XSTYPE_LIST)
39 ruri = xs_dict_get(ruri, 0);
40