commit bec8e88

default  ·  2023-05-31 09:13:06 +0000 UTC
parent a3eb84b
Started voting on mastoapi (non-working).
1 files changed,  +37, -0
+37, -0
 1@@ -2120,6 +2120,43 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
 2         else
 3             status = 401;
 4     }
 5+    else
 6+    if (xs_startswith(cmd, "/v1/polls")) { /** **/
 7+        if (logged_in) {
 8+            /* operations on a status */
 9+            xs *l = xs_split(cmd, "/");
10+            const char *mid = xs_list_get(l, 3);
11+            const char *op  = xs_list_get(l, 4);
12+
13+            if (!xs_is_null(mid)) {
14+                xs *msg = NULL;
15+                xs *out = NULL;
16+
17+                /* skip the 'fake' part of the id */
18+                mid = MID_TO_MD5(mid);
19+
20+                if (valid_status(timeline_get_by_md5(&snac, mid, &msg))) {
21+                    if (op == NULL) {
22+                    }
23+                    else
24+                    if (strcmp(op, "votes") == 0) {
25+                        const char *opts = xs_dict_get(args, "choices[]");
26+
27+                        if (xs_type(opts) == XSTYPE_LIST) {
28+                        }
29+                    }
30+                }
31+
32+                if (out != NULL) {
33+                    *body  = xs_json_dumps_pp(out, 4);
34+                    *ctype = "application/json";
35+                    status = 200;
36+                }
37+            }
38+        }
39+        else
40+            status = 401;
41+    }
42 
43     /* user cleanup */
44     if (logged_in)