aboutsummaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorgrunfink <grunfink@noreply.codeberg.org>2025-01-15 05:52:27 +0000
committergrunfink <grunfink@noreply.codeberg.org>2025-01-15 05:52:27 +0000
commitd7c24d146e85a6aa5074dbd6f0094b416d9ff4af (patch)
treecd4943dc9ac3a13899ae23e0a0c10efcb86a8a25 /mastoapi.c
parent061fa60171f157c064bceb990a9fbc9ae472b535 (diff)
parent9686ccd916464a1280082a4abba7a5fa3574dd0c (diff)
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.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 21e2a78..3e823ed 100644
--- 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)));