aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex14
-rw-r--r--lib/pleroma/web/router.ex1
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index 971772810..dacb0ebe3 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -308,7 +308,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
end
end
- def search(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do
+ def dousersearch(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do
if params["resolve"] == "true" do
User.get_or_fetch_by_nickname(query)
end
@@ -317,6 +317,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
where: fragment("(to_tsvector('english', ?) || to_tsvector('english', ?)) @@ plainto_tsquery('english', ?)", u.nickname, u.name, ^query),
limit: 20
accounts = Repo.all(q)
+ end
+
+ def search(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do
+ accounts = Pleroma.Web.MastodonAPI.MastodonAPIController.dousersearch(conn, params)
q = from a in Activity,
where: fragment("?->>'type' = 'Create'", a.data),
@@ -333,6 +337,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
json(conn, res)
end
+ def accountsearch(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do
+ accounts = Pleroma.Web.MastodonAPI.MastodonAPIController.dousersearch(conn, params)
+
+ res = AccountView.render("accounts.json", users: accounts, for: user, as: :user)
+
+ json(conn, res)
+ end
+
def favourites(%{assigns: %{user: user}} = conn, params) do
params = conn
|> Map.put("type", "Create")
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 45c47eefb..53f4a45e3 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -55,6 +55,7 @@ defmodule Pleroma.Web.Router do
get "/accounts/verify_credentials", MastodonAPIController, :verify_credentials
get "/accounts/relationships", MastodonAPIController, :relationships
+ get "/accounts/search", MastodonAPIController, :accountsearch
post "/accounts/:id/follow", MastodonAPIController, :follow
post "/accounts/:id/unfollow", MastodonAPIController, :unfollow
post "/accounts/:id/block", MastodonAPIController, :relationship_noop