summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-04-15 18:06:18 +0200
committerGravatar default2023-04-15 18:06:18 +0200
commit512058bbc5fc02496110aa293240c64951e174f6 (patch)
tree3aa94fb8ad640187e038e533df284da926fbe7a6
parentAdded some more dummy entry points. (diff)
downloadpenes-snac2-512058bbc5fc02496110aa293240c64951e174f6.tar.gz
penes-snac2-512058bbc5fc02496110aa293240c64951e174f6.tar.xz
penes-snac2-512058bbc5fc02496110aa293240c64951e174f6.zip
Added entrypoint /push/subscription.
The returned object is just wild guessing, I don't understand all this things. Anyway, the offical app keeps crashing.
-rw-r--r--mastoapi.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 4c3b5af..8c2684c 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -1009,17 +1009,24 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1009 ins = xs_dict_append(ins, "source_url", "https:/" "/comam.es/what-is-snac"); 1009 ins = xs_dict_append(ins, "source_url", "https:/" "/comam.es/what-is-snac");
1010 ins = xs_dict_append(ins, "description", host); 1010 ins = xs_dict_append(ins, "description", host);
1011 1011
1012 ins = xs_dict_append(ins, "short_description", host);
1013
1012 xs *susie = xs_fmt("%s/susie.png", srv_baseurl); 1014 xs *susie = xs_fmt("%s/susie.png", srv_baseurl);
1013 ins = xs_dict_append(ins, "thumbnail", susie); 1015 ins = xs_dict_append(ins, "thumbnail", susie);
1014 1016
1015 xs *d2 = xs_dict_new(); 1017 ins = xs_dict_append(ins, "email", "admin@localhost");
1016 d2 = xs_dict_append(d2, "email", "admin@localhost");
1017 ins = xs_dict_append(ins, "contact", d2);
1018 1018
1019 xs *l1 = xs_list_new(); 1019 xs *l1 = xs_list_new();
1020 ins = xs_dict_append(ins, "rules", l1); 1020 ins = xs_dict_append(ins, "rules", l1);
1021
1022 l1 = xs_list_append(l1, "en");
1021 ins = xs_dict_append(ins, "languages", l1); 1023 ins = xs_dict_append(ins, "languages", l1);
1022 1024
1025 xs *d1 = xs_dict_new();
1026 ins = xs_dict_append(ins, "urls", d1);
1027 ins = xs_dict_append(ins, "stats", d1);
1028 ins = xs_dict_append(ins, "configuration", d1);
1029
1023 *body = xs_json_dumps_pp(ins, 4); 1030 *body = xs_json_dumps_pp(ins, 4);
1024 *ctype = "application/json"; 1031 *ctype = "application/json";
1025 status = 200; 1032 status = 200;
@@ -1164,7 +1171,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
1164/* { 1171/* {
1165 xs *j = xs_json_dumps_pp(req, 4); 1172 xs *j = xs_json_dumps_pp(req, 4);
1166 printf("mastoapi post:\n%s\n", j); 1173 printf("mastoapi post:\n%s\n", j);
1167 }*/ 1174 }*/
1168 1175
1169 int status = 404; 1176 int status = 404;
1170 xs *args = NULL; 1177 xs *args = NULL;
@@ -1333,6 +1340,35 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
1333 else 1340 else
1334 status = 401; 1341 status = 401;
1335 } 1342 }
1343 else
1344 if (strcmp(cmd, "/push/subscription") == 0) {
1345 /* I don't know what I'm doing */
1346 if (logged_in) {
1347 char *v;
1348
1349 xs *wpush = xs_dict_new();
1350
1351 wpush = xs_dict_append(wpush, "id", "1");
1352
1353 v = xs_dict_get(args, "data");
1354 v = xs_dict_get(v, "alerts");
1355 wpush = xs_dict_append(wpush, "alerts", v);
1356
1357 v = xs_dict_get(args, "subscription");
1358 v = xs_dict_get(v, "endpoint");
1359 wpush = xs_dict_append(wpush, "endpoint", v);
1360
1361 xs *server_key = random_str();
1362 wpush = xs_dict_append(wpush, "server_key", server_key);
1363
1364 *body = xs_json_dumps_pp(wpush, 4);
1365 *ctype = "application/json";
1366 status = 200;
1367 }
1368 else
1369 status = 401;
1370
1371 }
1336 1372
1337 /* user cleanup */ 1373 /* user cleanup */
1338 if (logged_in) 1374 if (logged_in)