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
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),
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")
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