commit 9686ccd916464a1280082a4abba7a5fa3574dd0c
parent a016045a8fb80e4accad618c60b987bad708f45e
Author: Paul Martin <pm@nowster.org.uk>
Date: Tue, 14 Jan 2025 22:17:46 +0000
Implement limit= on notification fetches
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)));