fix bug in inbound
[akkoma] / lib / pleroma / search / elasticsearch.ex
index af2e13e48be4640691032d9252aabdc184e33944..181009ad61587dffd9b6e17ebdb31ad5b878d915 100644 (file)
@@ -2,6 +2,7 @@ defmodule Pleroma.Search.Elasticsearch do
   @behaviour Pleroma.Search
 
   alias Pleroma.Web.MastodonAPI.StatusView
+  alias Pleroma.Web.ActivityPub.Visibility
 
   defp to_es(term) when is_binary(term) do
     %{
@@ -47,7 +48,7 @@ defmodule Pleroma.Search.Elasticsearch do
     q = %{
       query: %{
         bool: %{
-          must: parse(query)
+          must: parse(String.trim(query))
         }
       }
     }
@@ -62,6 +63,7 @@ defmodule Pleroma.Search.Elasticsearch do
         |> Map.get("hits", [])
         |> Enum.map(fn result -> result["_id"] end)
         |> Pleroma.Activity.all_by_ids_with_object()
+       |> Enum.filter(fn x -> Visibility.visible_for_user?(x, user) end)
 
       %{
         "accounts" => [],