commit f7baafb

grunfink  ·  2024-05-31 07:00:13 +0000 UTC
parents eed9324, 795790d
Merge pull request 'Fix login issues with Mastodon, IceCube, Toot! on iOS' (#174) from louis77/snac2:apps into master

Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/174
1 files changed,  +13, -6
+13, -6
 1@@ -152,6 +152,7 @@ const char *login_page = ""
 2 "<html>\n"
 3 "<head>\n"
 4 "<title>%s OAuth - Snac2</title>\n"
 5+"<meta content=\"width=device-width, initial-scale=1, minimum-scale=1, user-scalable=no\" name=\"viewport\">"
 6 "<style>:root {color-scheme: light dark}</style>\n"
 7 "</head>\n"
 8 "<body><h1>%s OAuth identify</h1>\n"
 9@@ -338,11 +339,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
10         const char *cid   = xs_dict_get(args, "client_id");
11         const char *csec  = xs_dict_get(args, "client_secret");
12         const char *ruri  = xs_dict_get(args, "redirect_uri");
13-        /* FIXME: this 'scope' parameter is mandatory for the official Mastodon API,
14-           but if it's enabled, it makes it crash after some more steps, which
15-           is FAR WORSE */
16-        const char *scope = NULL;
17-//        scope = xs_dict_get(args, "scope");
18+        const char *scope = xs_dict_get(args, "scope");
19 
20         /* no client_secret? check if it's inside an authorization header
21            (AndStatus does it this way) */
22@@ -1164,8 +1161,10 @@ void credentials_get(char **body, char **ctype, int *status, snac snac)
23     acct = xs_dict_append(acct, "url", snac.actor);
24     acct = xs_dict_append(acct, "locked", xs_stock(XSTYPE_FALSE));
25     acct = xs_dict_append(acct, "bot", xs_dict_get(snac.config, "bot"));
26+    acct = xs_dict_append(acct, "emojis", xs_list_new());
27 
28-    xs *src = xs_json_loads("{\"privacy\":\"public\","
29+    xs *src = xs_json_loads("{\"privacy\":\"public\", \"language\":\"en\","
30+        "\"follow_requests_count\": 0,"
31         "\"sensitive\":false,\"fields\":[],\"note\":\"\"}");
32     /* some apps take the note from the source object */
33     src = xs_dict_set(src, "note", xs_dict_get(snac.config, "bio"));
34@@ -2378,6 +2377,14 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
35         const char *ruri  = xs_dict_get(args, "redirect_uris");
36         const char *scope = xs_dict_get(args, "scope");
37 
38+        /* Ice Cubes sends these values as query parameters, so try these */
39+        if (name == NULL && ruri == NULL && scope == NULL) {
40+            args = xs_dup(xs_dict_get(req, "q_vars"));
41+            name  = xs_dict_get(args, "client_name");
42+            ruri  = xs_dict_get(args, "redirect_uris");
43+            scope = xs_dict_get(args, "scope");
44+        }
45+
46         if (xs_type(ruri) == XSTYPE_LIST)
47             ruri = xs_dict_get(ruri, 0);
48