summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--httpd.c12
-rw-r--r--mastoapi.c12
2 files changed, 18 insertions, 6 deletions
diff --git a/httpd.c b/httpd.c
index 3fafeb0..1145abd 100644
--- a/httpd.c
+++ b/httpd.c
@@ -153,7 +153,7 @@ void httpd_connection(FILE *f)
153 d_char *body = NULL; 153 d_char *body = NULL;
154 int b_size = 0; 154 int b_size = 0;
155 char *ctype = NULL; 155 char *ctype = NULL;
156 xs *headers = NULL; 156 xs *headers = xs_dict_new();
157 xs *q_path = NULL; 157 xs *q_path = NULL;
158 xs *payload = NULL; 158 xs *payload = NULL;
159 xs *etag = NULL; 159 xs *etag = NULL;
@@ -232,9 +232,10 @@ void httpd_connection(FILE *f)
232#endif 232#endif
233 233
234 } 234 }
235 235 else
236 /* let's go */ 236 if (strcmp(method, "OPTIONS") == 0) {
237 headers = xs_dict_new(); 237 status = 200;
238 }
238 239
239 /* unattended? it's an error */ 240 /* unattended? it's an error */
240 if (status == 0) { 241 if (status == 0) {
@@ -275,6 +276,9 @@ void httpd_connection(FILE *f)
275 if (strcmp(method, "HEAD") == 0) 276 if (strcmp(method, "HEAD") == 0)
276 body = xs_free(body); 277 body = xs_free(body);
277 278
279 headers = xs_dict_append(headers, "access-control-allow-origin", "*");
280 headers = xs_dict_append(headers, "access-control-allow-headers", "*");
281
278 xs_httpd_response(f, status, headers, body, b_size); 282 xs_httpd_response(f, status, headers, body, b_size);
279 283
280 fclose(f); 284 fclose(f);
diff --git a/mastoapi.c b/mastoapi.c
index 2acef04..172d03a 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -11,6 +11,7 @@
11#include "xs_glob.h" 11#include "xs_glob.h"
12#include "xs_set.h" 12#include "xs_set.h"
13#include "xs_random.h" 13#include "xs_random.h"
14#include "xs_httpd.h"
14 15
15#include "snac.h" 16#include "snac.h"
16 17
@@ -234,6 +235,11 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
234 if (i_ctype && xs_startswith(i_ctype, "application/json")) 235 if (i_ctype && xs_startswith(i_ctype, "application/json"))
235 args = xs_json_loads(payload); 236 args = xs_json_loads(payload);
236 else 237 else
238 if (i_ctype && xs_startswith(i_ctype, "application/x-www-form-urlencoded") && payload) {
239 xs *upl = xs_url_dec(payload);
240 args = xs_url_vars(upl);
241 }
242 else
237 args = xs_dup(xs_dict_get(req, "p_vars")); 243 args = xs_dup(xs_dict_get(req, "p_vars"));
238 244
239 xs *cmd = xs_replace_n(q_path, "/oauth", "", 1); 245 xs *cmd = xs_replace_n(q_path, "/oauth", "", 1);
@@ -954,6 +960,10 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
954 acct = xs_dict_append(acct, "url", snac1.actor); 960 acct = xs_dict_append(acct, "url", snac1.actor);
955 acct = xs_dict_append(acct, "header", ""); 961 acct = xs_dict_append(acct, "header", "");
956 962
963 xs *src = xs_json_loads("{\"privacy\":\"public\","
964 "\"sensitive\":false,\"fields\":[],\"note\":\"\"}");
965 acct = xs_dict_append(acct, "source", src);
966
957 xs *avatar = NULL; 967 xs *avatar = NULL;
958 char *av = xs_dict_get(snac1.config, "avatar"); 968 char *av = xs_dict_get(snac1.config, "avatar");
959 969
@@ -1458,8 +1468,6 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1458 ins = xs_dict_append(ins, "languages", l1); 1468 ins = xs_dict_append(ins, "languages", l1);
1459 1469
1460 xs *d1 = xs_dict_new(); 1470 xs *d1 = xs_dict_new();
1461 xs *wss = xs_replace(srv_baseurl, "https:", "wss:");
1462 d1 = xs_dict_append(d1, "streaming_api", wss);
1463 ins = xs_dict_append(ins, "urls", d1); 1471 ins = xs_dict_append(ins, "urls", d1);
1464 1472
1465 xs *z = xs_number_new(0); 1473 xs *z = xs_number_new(0);