forked from AkkomaGang/akkoma
Merge branch 'feature/mastodon-search-tags' into 'develop'
mastodon search api: implement a reasonable hashtags stub See merge request pleroma/pleroma!89
This commit is contained in:
commit
978df55a86
1 changed files with 5 additions and 1 deletions
|
@ -513,12 +513,16 @@ def search(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do
|
||||||
)
|
)
|
||||||
|
|
||||||
statuses = Repo.all(q) ++ fetched
|
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 = %{
|
res = %{
|
||||||
"accounts" => AccountView.render("accounts.json", users: accounts, for: user, as: :user),
|
"accounts" => AccountView.render("accounts.json", users: accounts, for: user, as: :user),
|
||||||
"statuses" =>
|
"statuses" =>
|
||||||
StatusView.render("index.json", activities: statuses, for: user, as: :activity),
|
StatusView.render("index.json", activities: statuses, for: user, as: :activity),
|
||||||
"hashtags" => []
|
"hashtags" => tags
|
||||||
}
|
}
|
||||||
|
|
||||||
json(conn, res)
|
json(conn, res)
|
||||||
|
|
Loading…
Reference in a new issue