From e960267b707be9308696946fb90998517ca6cf64 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Tue, 12 Nov 2024 09:10:22 +0100 Subject: [PATCH] Add min_id and max_id options to search --- toot/api.py | 14 +++++++++++++- toot/cli/read.py | 6 +++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/toot/api.py b/toot/api.py index 53e4c78..339710f 100644 --- a/toot/api.py +++ b/toot/api.py @@ -549,7 +549,17 @@ def _add_mime_type(file): return (filename, file, mime_type) -def search(app, user, query, resolve=False, type=None, offset=None, limit=None): +def search( + app, + user, + query, + resolve=False, + type=None, + offset=None, + limit=None, + min_id=None, + max_id=None, +): """ Perform a search. https://docs.joinmastodon.org/methods/search/#v2 @@ -560,6 +570,8 @@ def search(app, user, query, resolve=False, type=None, offset=None, limit=None): "type": type, "offset": offset, "limit": limit, + "min_id": min_id, + "max_id": max_id, }) return http.get(app, user, "/api/v2/search", params) diff --git a/toot/cli/read.py b/toot/cli/read.py index 8ec076d..57f34b7 100644 --- a/toot/cli/read.py +++ b/toot/cli/read.py @@ -82,6 +82,8 @@ def instance(instance: Optional[str], json: bool): ) @click.option("-o", "--offset", type=int, help="Return results starting from (default 0)") @click.option("-l", "--limit", type=int, help="Maximum number of results to return, per type. (default 20, max 40)") +@click.option("--min-id", help="Return results newer than this ID.") +@click.option("--max-id", help="Return results older than this ID.") @json_option @pass_context def search( @@ -91,10 +93,12 @@ def search( type: Optional[str], offset: Optional[int], limit: Optional[int], + min_id: Optional[str], + max_id: Optional[str], json: bool ): """Search for content in accounts, statuses and hashtags.""" - response = api.search(ctx.app, ctx.user, query, resolve, type, offset, limit) + response = api.search(ctx.app, ctx.user, query, resolve, type, offset, limit, min_id, max_id) if json: click.echo(response.text) else: