commit d7c24d146e85a6aa5074dbd6f0094b416d9ff4af
parent 061fa60171f157c064bceb990a9fbc9ae472b535
Author: grunfink <grunfink@noreply.codeberg.org>
Date: Wed, 15 Jan 2025 05:52:27 +0000
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:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/mastoapi.c b/mastoapi.c
@@ -1816,6 +1816,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
const xs_list *excl = xs_dict_get(args, "exclude_types[]");
const char *min_id = xs_dict_get(args, "min_id");
const char *max_id = xs_dict_get(args, "max_id");
+ const char *limit = xs_dict_get(args, "limit");
+ int limit_count = 0;
+ if (!xs_is_null(limit)) {
+ limit_count = atoi(limit);
+ }
if (dbglevel) {
xs *js = xs_json_dumps(args, 0);
@@ -1903,6 +1908,10 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
}
out = xs_list_append(out, mn);
+ if (!xs_is_null(limit)) {
+ if (--limit_count <= 0)
+ break;
+ }
}
srv_debug(1, xs_fmt("mastoapi_notifications count %d", xs_list_len(out)));