aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2018-04-01 07:08:05 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2018-04-01 02:12:10 -0500
commit2dcc6037d038cdc187e850cc42b3863a5d449c91 (patch)
treeb6c9cc97365966b24bd23251e8220258c9a26c31
parent5fa8237bc1dcabca050dc5d8d9325fec649e1723 (diff)
downloadpleroma-2dcc6037d038cdc187e850cc42b3863a5d449c91.tar.gz
mastodon search api: implement a reasonable hashtags stub
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex6
1 files changed, 5 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 58bb5e03a..dc92e30c5 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -513,12 +513,16 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
)
statuses = Repo.all(q) ++ fetched
+ tags = String.split(query)
+ |> Enum.uniq()
+ |> Enum.filter(fn tag -> String.starts_with?(tag, "#") end)
+ |> Enum.map(fn tag -> String.slice(tag, 1..-1) end)
res = %{
"accounts" => AccountView.render("accounts.json", users: accounts, for: user, as: :user),
"statuses" =>
StatusView.render("index.json", activities: statuses, for: user, as: :activity),
- "hashtags" => []
+ "hashtags" => tags
}
json(conn, res)