Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Add from: search operator and account_id query param #2943

Merged
merged 5 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2872,6 +2872,9 @@ paths:
- `https://example.org/some/arbitrary/url` -- search for an account OR a status with the given URL. Will only ever return 1 result at most.
- `#[hashtag_name]` -- search for a hashtag with the given hashtag name, or starting with the given hashtag name. Case insensitive. Can return multiple results.
- any arbitrary string -- search for accounts or statuses containing the given string. Can return multiple results.

Arbitrary string queries may include the following operators:
- `from:localuser`, `from:[email protected]`: restrict results to statuses created by the specified account.
in: query
name: q
required: true
Expand Down Expand Up @@ -2902,6 +2905,10 @@ paths:
in: query
name: exclude_unreviewed
type: boolean
- description: Restrict results to statuses created by the specified account.
in: query
name: account_id
type: string
produces:
- application/json
responses:
Expand Down
10 changes: 10 additions & 0 deletions internal/api/client/search/searchget.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ import (
// - `https://example.org/some/arbitrary/url` -- search for an account OR a status with the given URL. Will only ever return 1 result at most.
// - `#[hashtag_name]` -- search for a hashtag with the given hashtag name, or starting with the given hashtag name. Case insensitive. Can return multiple results.
// - any arbitrary string -- search for accounts or statuses containing the given string. Can return multiple results.
//
// Arbitrary string queries may include the following operators:
// - `from:localuser`, `from:[email protected]`: restrict results to statuses created by the specified account.
// in: query
// required: true
// -
Expand Down Expand Up @@ -138,6 +141,12 @@ import (
// Currently this parameter is unused.
// default: false
// in: query
// -
// name: account_id
// type: string
// description: >-
// Restrict results to statuses created by the specified account.
// in: query
//
// security:
// - OAuth2 Bearer:
Expand Down Expand Up @@ -238,6 +247,7 @@ func (m *Module) SearchGETHandler(c *gin.Context) {
Resolve: resolve,
Following: following,
ExcludeUnreviewed: excludeUnreviewed,
AccountID: c.Query(apiutil.SearchAccountIDKey),
APIv1: apiVersion == apiutil.APIv1,
}

Expand Down
Loading