Merge branch 'feld-warnings' into 'develop'
[akkoma] / lib / pleroma / web / twitter_api / twitter_api.ex
index 30362ef7049590efdfa9aa2e63dd86a52c5e097d..44ea40a4e4e8bdb6cbf1b08fb3d1d260b969b334 100644 (file)
@@ -1,7 +1,6 @@
 defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
   alias Pleroma.{User, Activity, Repo, Object}
   alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter
   alias Pleroma.Web.TwitterAPI.UserView
   alias Pleroma.Web.{OStatus, CommonAPI}
   import Ecto.Query
@@ -184,7 +183,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
 
   defp parse_int(_, default), do: default
 
-  def search(user, %{"q" => query} = params) do
+  def search(_user, %{"q" => query} = params) do
     limit = parse_int(params["rpp"], 20)
     page = parse_int(params["page"], 1)
     offset = (page - 1) * limit
@@ -193,6 +192,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
       from(
         a in Activity,
         where: fragment("?->>'type' = 'Create'", a.data),
+        where: "https://www.w3.org/ns/activitystreams#Public" in a.recipients,
         where:
           fragment(
             "to_tsvector('english', ?->'object'->>'content') @@ plainto_tsquery('english', ?)",
@@ -205,13 +205,14 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
         order_by: [desc: :inserted_at]
       )
 
-    activities = Repo.all(q)
+    _activities = Repo.all(q)
   end
 
   defp make_date do
     DateTime.utc_now() |> DateTime.to_iso8601()
   end
 
+  # DEPRECATED mostly, context objects are now created at insertion time.
   def context_to_conversation_id(context) do
     with %Object{id: id} <- Object.get_cached_by_ap_id(context) do
       id