diff options
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 58 |
1 files changed, 51 insertions, 7 deletions
| @@ -1802,6 +1802,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1802 | xs *out = xs_list_new(); | 1802 | xs *out = xs_list_new(); |
| 1803 | const xs_dict *v; | 1803 | const xs_dict *v; |
| 1804 | const xs_list *excl = xs_dict_get(args, "exclude_types[]"); | 1804 | const xs_list *excl = xs_dict_get(args, "exclude_types[]"); |
| 1805 | const char *min_id = xs_dict_get(args, "min_id"); | ||
| 1805 | const char *max_id = xs_dict_get(args, "max_id"); | 1806 | const char *max_id = xs_dict_get(args, "max_id"); |
| 1806 | 1807 | ||
| 1807 | xs_list_foreach(l, v) { | 1808 | xs_list_foreach(l, v) { |
| @@ -1828,10 +1829,14 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1828 | continue; | 1829 | continue; |
| 1829 | 1830 | ||
| 1830 | if (max_id) { | 1831 | if (max_id) { |
| 1831 | if (strcmp(fid, max_id) == 0) | 1832 | if (strcmp(fid, max_id) > 0) |
| 1832 | max_id = NULL; | 1833 | continue; |
| 1834 | } | ||
| 1833 | 1835 | ||
| 1834 | continue; | 1836 | if (min_id) { |
| 1837 | if (strcmp(fid, min_id) <= 0) { | ||
| 1838 | continue; | ||
| 1839 | } | ||
| 1835 | } | 1840 | } |
| 1836 | 1841 | ||
| 1837 | /* convert the type */ | 1842 | /* convert the type */ |
| @@ -2312,9 +2317,22 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2312 | } | 2317 | } |
| 2313 | else | 2318 | else |
| 2314 | if (strcmp(cmd, "/v1/markers") == 0) { /** **/ | 2319 | if (strcmp(cmd, "/v1/markers") == 0) { /** **/ |
| 2315 | *body = xs_dup("{}"); | 2320 | if (logged_in) { |
| 2316 | *ctype = "application/json"; | 2321 | const xs_list *timeline = xs_dict_get(args, "timeline[]"); |
| 2317 | status = HTTP_STATUS_OK; | 2322 | xs_str *json = NULL; |
| 2323 | if (!xs_is_null(timeline)) | ||
| 2324 | json = xs_json_dumps(markers_get(&snac1, timeline), 4); | ||
| 2325 | |||
| 2326 | if (!xs_is_null(json)) | ||
| 2327 | *body = json; | ||
| 2328 | else | ||
| 2329 | *body = xs_dup("{}"); | ||
| 2330 | |||
| 2331 | *ctype = "application/json"; | ||
| 2332 | status = HTTP_STATUS_OK; | ||
| 2333 | } | ||
| 2334 | else | ||
| 2335 | status = HTTP_STATUS_UNAUTHORIZED; | ||
| 2318 | } | 2336 | } |
| 2319 | else | 2337 | else |
| 2320 | if (strcmp(cmd, "/v1/followed_tags") == 0) { /** **/ | 2338 | if (strcmp(cmd, "/v1/followed_tags") == 0) { /** **/ |
| @@ -3011,9 +3029,35 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 3011 | } | 3029 | } |
| 3012 | } | 3030 | } |
| 3013 | } | 3031 | } |
| 3032 | } | ||
| 3033 | else if (strcmp(cmd, "/v1/markers") == 0) { /** **/ | ||
| 3034 | xs_str *json = NULL; | ||
| 3035 | if (logged_in) { | ||
| 3036 | const xs_str *home_marker = xs_dict_get(args, "home[last_read_id]"); | ||
| 3037 | if (xs_is_null(home_marker)) { | ||
| 3038 | const xs_dict *home = xs_dict_get(args, "home"); | ||
| 3039 | if (!xs_is_null(home)) | ||
| 3040 | home_marker = xs_dict_get(home, "last_read_id"); | ||
| 3041 | } | ||
| 3042 | |||
| 3043 | const xs_str *notify_marker = xs_dict_get(args, "notifications[last_read_id]"); | ||
| 3044 | if (xs_is_null(notify_marker)) { | ||
| 3045 | const xs_dict *notify = xs_dict_get(args, "notifications"); | ||
| 3046 | if (!xs_is_null(notify)) | ||
| 3047 | notify_marker = xs_dict_get(notify, "last_read_id"); | ||
| 3048 | } | ||
| 3049 | json = xs_json_dumps(markers_set(&snac, home_marker, notify_marker), 4); | ||
| 3050 | } | ||
| 3051 | if (!xs_is_null(json)) | ||
| 3052 | *body = json; | ||
| 3014 | else | 3053 | else |
| 3015 | status = HTTP_STATUS_UNPROCESSABLE_CONTENT; | 3054 | *body = xs_dup("{}"); |
| 3055 | |||
| 3056 | *ctype = "application/json"; | ||
| 3057 | status = HTTP_STATUS_OK; | ||
| 3016 | } | 3058 | } |
| 3059 | else | ||
| 3060 | status = HTTP_STATUS_UNPROCESSABLE_CONTENT; | ||
| 3017 | 3061 | ||
| 3018 | /* user cleanup */ | 3062 | /* user cleanup */ |
| 3019 | if (logged_in) | 3063 | if (logged_in) |