mastodon search api: implement a reasonable hashtags stub
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 1 Apr 2018 07:08:05 +0000 (07:08 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sun, 1 Apr 2018 07:12:10 +0000 (02:12 -0500)
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

index 58bb5e03afe173b898459b91c1333eadfcf24bb6..dc92e30c5cec024ebe1ba138e6a97b5dc9557ab7 100644 (file)
@@ -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)