mastodon search api: implement a reasonable hashtags stub

This commit is contained in:
William Pitcock 2018-04-01 07:08:05 +00:00
parent 5fa8237bc1
commit 2dcc6037d0

View file

@ -513,12 +513,16 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController 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)