1
0
mirror of https://github.com/ihabunek/toot synced 2024-12-23 07:27:12 +01:00

Add min_id and max_id options to search

This commit is contained in:
Ivan Habunek 2024-11-12 09:10:22 +01:00
parent 803f36d1ed
commit e960267b70
No known key found for this signature in database
GPG Key ID: 01DB3DD0D824504C
2 changed files with 18 additions and 2 deletions

View File

@ -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)

View File

@ -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: