diff options
| author | 2025-01-15 05:52:27 +0000 | |
|---|---|---|
| committer | 2025-01-15 05:52:27 +0000 | |
| commit | d7c24d146e85a6aa5074dbd6f0094b416d9ff4af (patch) | |
| tree | cd4943dc9ac3a13899ae23e0a0c10efcb86a8a25 /mastoapi.c | |
| parent | Updated RELEASE_NOTES. (diff) | |
| parent | Implement limit= on notification fetches (diff) | |
| download | snac2-d7c24d146e85a6aa5074dbd6f0094b416d9ff4af.tar.gz snac2-d7c24d146e85a6aa5074dbd6f0094b416d9ff4af.tar.xz snac2-d7c24d146e85a6aa5074dbd6f0094b416d9ff4af.zip | |
Merge pull request 'Implement limit= on notification fetches' (#276) from nowster/snac2:notification_limits into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/276
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))); |