diff options
| author | 2025-01-14 22:17:46 +0000 | |
|---|---|---|
| committer | 2025-01-14 22:17:46 +0000 | |
| commit | 9686ccd916464a1280082a4abba7a5fa3574dd0c (patch) | |
| tree | dfd34eefe4bebd23a503967633da5f3ad2d9acc3 /mastoapi.c | |
| parent | Don't describe as 'fatal' what are just non-retriable connection errors. (diff) | |
| download | snac2-9686ccd916464a1280082a4abba7a5fa3574dd0c.tar.gz snac2-9686ccd916464a1280082a4abba7a5fa3574dd0c.tar.xz snac2-9686ccd916464a1280082a4abba7a5fa3574dd0c.zip | |
Implement limit= on notification fetches
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 9 |
1 files changed, 9 insertions, 0 deletions
| @@ -1816,6 +1816,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1816 | const xs_list *excl = xs_dict_get(args, "exclude_types[]"); | 1816 | const xs_list *excl = xs_dict_get(args, "exclude_types[]"); |
| 1817 | const char *min_id = xs_dict_get(args, "min_id"); | 1817 | const char *min_id = xs_dict_get(args, "min_id"); |
| 1818 | const char *max_id = xs_dict_get(args, "max_id"); | 1818 | const char *max_id = xs_dict_get(args, "max_id"); |
| 1819 | const char *limit = xs_dict_get(args, "limit"); | ||
| 1820 | int limit_count = 0; | ||
| 1821 | if (!xs_is_null(limit)) { | ||
| 1822 | limit_count = atoi(limit); | ||
| 1823 | } | ||
| 1819 | 1824 | ||
| 1820 | if (dbglevel) { | 1825 | if (dbglevel) { |
| 1821 | xs *js = xs_json_dumps(args, 0); | 1826 | xs *js = xs_json_dumps(args, 0); |
| @@ -1903,6 +1908,10 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1903 | } | 1908 | } |
| 1904 | 1909 | ||
| 1905 | out = xs_list_append(out, mn); | 1910 | out = xs_list_append(out, mn); |
| 1911 | if (!xs_is_null(limit)) { | ||
| 1912 | if (--limit_count <= 0) | ||
| 1913 | break; | ||
| 1914 | } | ||
| 1906 | } | 1915 | } |
| 1907 | 1916 | ||
| 1908 | srv_debug(1, xs_fmt("mastoapi_notifications count %d", xs_list_len(out))); | 1917 | srv_debug(1, xs_fmt("mastoapi_notifications count %d", xs_list_len(out))); |