diff options
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 37 |
1 files changed, 37 insertions, 0 deletions
| @@ -2120,6 +2120,43 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2120 | else | 2120 | else |
| 2121 | status = 401; | 2121 | status = 401; |
| 2122 | } | 2122 | } |
| 2123 | else | ||
| 2124 | if (xs_startswith(cmd, "/v1/polls")) { /** **/ | ||
| 2125 | if (logged_in) { | ||
| 2126 | /* operations on a status */ | ||
| 2127 | xs *l = xs_split(cmd, "/"); | ||
| 2128 | const char *mid = xs_list_get(l, 3); | ||
| 2129 | const char *op = xs_list_get(l, 4); | ||
| 2130 | |||
| 2131 | if (!xs_is_null(mid)) { | ||
| 2132 | xs *msg = NULL; | ||
| 2133 | xs *out = NULL; | ||
| 2134 | |||
| 2135 | /* skip the 'fake' part of the id */ | ||
| 2136 | mid = MID_TO_MD5(mid); | ||
| 2137 | |||
| 2138 | if (valid_status(timeline_get_by_md5(&snac, mid, &msg))) { | ||
| 2139 | if (op == NULL) { | ||
| 2140 | } | ||
| 2141 | else | ||
| 2142 | if (strcmp(op, "votes") == 0) { | ||
| 2143 | const char *opts = xs_dict_get(args, "choices[]"); | ||
| 2144 | |||
| 2145 | if (xs_type(opts) == XSTYPE_LIST) { | ||
| 2146 | } | ||
| 2147 | } | ||
| 2148 | } | ||
| 2149 | |||
| 2150 | if (out != NULL) { | ||
| 2151 | *body = xs_json_dumps_pp(out, 4); | ||
| 2152 | *ctype = "application/json"; | ||
| 2153 | status = 200; | ||
| 2154 | } | ||
| 2155 | } | ||
| 2156 | } | ||
| 2157 | else | ||
| 2158 | status = 401; | ||
| 2159 | } | ||
| 2123 | 2160 | ||
| 2124 | /* user cleanup */ | 2161 | /* user cleanup */ |
| 2125 | if (logged_in) | 2162 | if (logged_in) |