Skip to content

Commit

Permalink
Add min_id and max_id options to search
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabunek committed Nov 12, 2024
1 parent 803f36d commit e960267
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 13 additions & 1 deletion toot/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion toot/cli/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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:
Expand Down

0 comments on commit e960267

Please sign in to comment.