mirror of
https://github.com/ihabunek/toot
synced 2024-12-22 23:08:17 +01:00
Add min_id and max_id options to search
This commit is contained in:
parent
803f36d1ed
commit
e960267b70
14
toot/api.py
14
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)
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user