mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-14 03:24:04 +00:00
Add remote user fetching to search.
This commit is contained in:
parent
f0257c7516
commit
c36229c4aa
|
@ -287,7 +287,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def search(%{assigns: %{user: user}} = conn, %{"q" => query}) do
|
def search(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do
|
||||||
|
if params["resolve"] == "true" do
|
||||||
|
User.get_or_fetch_by_nickname(query)
|
||||||
|
end
|
||||||
|
|
||||||
q = from u in User,
|
q = from u in User,
|
||||||
where: fragment("(to_tsvector('english', ?) || to_tsvector('english', ?)) @@ plainto_tsquery('english', ?)", u.nickname, u.name, ^query),
|
where: fragment("(to_tsvector('english', ?) || to_tsvector('english', ?)) @@ plainto_tsquery('english', ?)", u.nickname, u.name, ^query),
|
||||||
limit: 20
|
limit: 20
|
||||||
|
|
|
@ -332,4 +332,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
||||||
[status] = results["statuses"]
|
[status] = results["statuses"]
|
||||||
assert status["id"] == activity.id
|
assert status["id"] == activity.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "search fetches remote accounts", %{conn: conn} do
|
||||||
|
conn = conn
|
||||||
|
|> get("/api/v1/search", %{"q" => "shp@social.heldscal.la", "resolve" => "true"})
|
||||||
|
|
||||||
|
assert results = json_response(conn, 200)
|
||||||
|
[account] = results["accounts"]
|
||||||
|
assert account["acct"] == "shp@social.heldscal.la"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue